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,请教各位了#include<iostream.h> #include<string.h> int main() { int n; cin>>n; for(int i=1;i<=n;i++) { int l,m; cin>>l>>m; l*=100; int *len=new int[m]; char (*d)[6]=new char[m][6]; for(int j=0;j<m;j++) { cin>>len[j]>>d[j]; } int s=0,s1=0; if(strcmp(d[0],"right")==0) { s++; } for(j=0;j<m;j++) { s1+=len[j]; if(j==m-1) { if(s1==0) { if(strcmp(d[j],d[j-1])==0) { s+=2; break; } else { s++; break; } } else { s++; break; } } if(s1+len[j+1]<=l&&strcmp(d[j],d[j+1])==0) { continue; } if(s1+len[j+1]<=l&&strcmp(d[j],d[j+1])!=0) { s++; s1=0; } if(s1+len[j+1]>l&&strcmp(d[j],d[j+1])!=0) { s++; s1=0; } if(s1+len[j+1]>l&&strcmp(d[j],d[j+1])==0) { s+=2; s1=0; } } cout<<s<<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