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 |
找了1个小时也没找到错的地方 请好心人帮忙看看啊 谢谢#include<iostream.h> #include<stdio.h> #include<math.h> int w[1001]; int a[101][10001]; char c[102]; int b[101]; bool check1[1001]; int main() { int N,K,i,j,n; scanf("%d%d",&N,&K); for (i=1;i<=N;i++) { w[i]=1; } for (i=0;i<K;i++) { cin>>b[i]; for (j=0;j<2*b[i];j++) { cin>>a[i][j]; check1[a[i][j]]=1; } cin>>c[i]; } int wl,wr,k; bool check; int sum=0; for (j=1;j<=N;j++) if(check1[j]==1)sum++; if(sum<=N-2){cout<<0<<endl;return 0;}//如果有2个硬币没有出现在数据中则输出0 for (i=1;i<=N;i++) { w[i]=2; for (j=0;j<K;j++)//枚举每一个硬币 { check=0; wl=wr=0; for (k=0;k<b[j];k++) wl+=w[a[j][k]]; for (k=b[j];k<2*b[j];k++) wr+=w[a[j][k]]; if(c[j]=='>') if(wl>wr) check=1;; if(c[j]=='<') if(wl<wr)check=1; if(c[j]=='=') if(wl==wr)check=1; if(check==0) break; } if(j==K) { cout<<i<<endl; return 0; } w[i]=0; for (j=0;j<K;j++) { check=0; wl=wr=0; for (k=0;k<b[j];k++) wl+=w[a[j][k]]; for (k=b[j];k<2*b[j];k++) wr+=w[a[j][k]]; if(c[j]=='>') if(wl>wr) check=1;; if(c[j]=='<') if(wl<wr)check=1; if(c[j]=='=') if(wl==wr)check=1; if(check==0) break; else check=0; } if(j==K) { cout<<i<<endl; return 0; } w[i]=1; } if(i==N+1)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