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

来源:互联网 发布:用python编写99乘法表 编辑:程序博客网 时间:2024/06/13 15:56

errors, clauses in place, logical ones, should be avoided.

#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;}
0 0
原创粉丝点击