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 |
小弟初学,请求牛人指点,这题为嘛WA(代码内附c++,写的不好见谅)#include<iostream> #include<memory> using namespace std; int main() { char c; bool flag[1001]; int light[1001],heavy[1001],n,k,pi,i,j,a[500],b[500],sum=0,num1=0; cin>>n>>k; memset(light,0,sizeof(light)); memset(heavy,0,sizeof(heavy)); for(i = 1 ; i <= n ; ++i) flag[i]=true; while(k != 0) { cin>>pi; for(i = 0 ; i != pi ; ++i) cin>>a[i]; for(i = 0 ; i != pi ; ++i) cin>>b[i]; cin>>c; if(c=='=') { for(i = 0 ; i != pi ; ++i) { flag[a[i]]=false; flag[b[i]]=false; } } if(c=='<') { ++sum; for(i = 0 ; i != pi ; ++i) { ++light[a[i]]; ++heavy[b[i]]; } } if(c=='>') { ++sum; for(i = 0 ; i != pi ; ++i) { ++light[b[i]]; ++heavy[a[i]]; } } --k; } if(sum==0) { for(i = 1 ; i != n ; ++i) { if(flag[i]) { ++num1; j=i; } } if(num1==1) cout<<j<<endl; else cout<<'0'<<endl; } else { for(i = 1 ; i != n ; ++i) if(flag[i] && ((light[i]==sum) || (heavy[i]==sum))) { ++num1; j=i; } if(num1==1) cout<<j<<endl; else cout<<'0'<<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