您的位置:首页 > 其它

hdu 1050 (preinitilization or postcleansing, std::fill)

2015-06-18 11:33 281 查看
errors, clauses in place, logical ones, should be avoided.

[code]#include <cstdio>
#include <cstring>
#include <algorithm>

int main() {
    //freopen("input.txt","r",stdin);
    const int CorNum=201;
    int ncase, npair, to,from, first,last, res;
    int shared[CorNum]={0};
    if(scanf("%d",&ncase)!=1) return -1;
    while(ncase-- && scanf("%d",&npair)==1) {
        first=CorNum, last=0;
        while(npair--) {
            scanf("%d%d",&from,&to);
            from=(from-1)>>1; to=(to-1)>>1;
            if(from>to) std::swap(from,to);
            first=std::min(first,from); last=std::max(last,to);
            for(;from<=to;++from) ++shared[from];
        }
        for(res=0,from=first;from<=last;++from) res=std::max(res,shared[from]);
        std::fill(&shared[first],&shared[last+1],0);
        printf("%d\n",res*10);
    }
    return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: