Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
其实输入一点也不恶心输入一个Q,然后有Q组(u,v)每组中间还有空格,tab等。但,稍稍想一下就能发现,Q组uv一共有Q*2个字符串,所以我们讲稿Q*2组str就可以了scanf("%s",str),然后处理每组str求得u,v int deal(char *s,int v){ int i,ret=0; if(v){ for(i=1;s[i];++i) ret*=10,ret+=s[i]-'0'; }else{ for(i=0;s[i+1];++i) ret*=10,ret+=s[i]-'0'; } //printf("ret=%d\n",ret); return ret; } int main(){ ......... int Q; char str[20]; scanf("%d",&Q); Q<<=1; for(i=0;i<Q;++i){ scanf("%s",str); if(i&1) v=deal(str,0),query[u].push_back(v),query[v].push_back(u); else u=deal(str,1);//后面那个1表示u,0表示v } ...... return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator