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 |
改成这样还是错。In Reply To:为什么总是WA啊。 Posted by:15017547261 at 2009-02-08 18:51:10 #include <iostream> using namespace std; int main(){ int t,output[200000],l=0,c[20000],d[20000]; char cmd; cin>>t; while(t--){ int n; cin>>n; cin>>cmd; memset(c,0,sizeof(c)); memset(d,0,sizeof(d)); while(cmd!='O'){ if(cmd=='E'){ int p; cin>>p; output[l++]=d[p]; }else{ int p,q; cin>>p>>q; d[p]=abs(p-q)%1000+d[q]; if(c[q]) c[p]=c[q]; else c[p]=q; for(int i=1;i<=n;i++){ if(c[i]==p){ c[i]=c[p]; d[i]+=d[p]; } } } cin>>cmd; } } for(int i=0;i<l;i++) cout<<output[i]<<endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator