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 |
有没有末尾少一空行能判PE的SPJ?不然WA的很郁闷的说In Reply To:Re:帮忙写一个? Posted by:hong_liming at 2004-04-20 18:47:11 > 我不太懂具体那些错误是怎么判断的,瞎写了一个。不过我自己的程序可是ac了:) > 我是用cin输入待judge的东西,cout输出judge的结果,原来的测试数据都用文件读进来。 > #include<fstream.h> > #include<iostream.h> > #include<string.h> > int picture[22][22]; > int r,c; > int peri,perj;//person > int boxi,boxj;//box > int desi,desj;//destination > > //int wall=0; > int space=-1; > > int position[4][2]={{0,1},{-1,0},{0,-1},{1,0}}; > char pos[2][5]={"ENWS","enws"}; > > void main() > { > int i,j,k,p,q,b1,b2,s1,s2; > char st1[2000],st2[2000],ch; > ifstream inp("pushing.in"); > ifstream oup("pushing.sol"); > do > { > inp>>r>>c;//读地图 > if(r==0&&c==0)break; > memset(picture,0,22*22*sizeof(int)); > for(i=1;i<=r;i++) > for(j=1;j<=c;j++) > { > inp>>ch; > if(ch=='S'){peri=i;perj=j;picture[i][j]=space;} > else if(ch=='B'){boxi=i;boxj=j;picture[i][j]=space;} > else if(ch=='.')picture[i][j]=space; > else if(ch=='T'){desi=i;desj=j;picture[i][j]=space;} > } > cin.getline(st1,2000,'\n');if(!cin){cout<<"wa"<<endl;goto final;} > oup.getline(st2,2000,'\n'); > if(strcmp(st1,st2)){cout<<"wa"<<endl;goto final;} > cin.getline(st1,2000,'\n');if(!cin){cout<<"wa"<<endl;goto final;} > oup.getline(st2,2000,'\n'); > if(!strcmp(st2,"Impossible.")) > if(strcmp(st1,st2)){cout<<"wa"<<endl;goto final;}else; > else > { > s1=b1=0;k=-1; > while(st1[++k]){if(st1[k]>='a'&&st1[k]<='z')s1++;if(st1[k]>='A'&&st1[k]<='Z')b1++;} > s2=b2=0;k=-1; > while(st2[++k]){if(st2[k]>='a'&&st2[k]<='z')s2++;if(st2[k]>='A'&&st2[k]<='Z')b2++;} > if(s1!=s2||b1!=b2){cout<<"wa"<<endl;goto final;} > k=-1; > while(st1[++k]) > { > if(st1[k]>='a'&&st1[k]<='z') > { > for(i=0;i<4;i++) > if(st1[k]==pos[1][i]) > { > p=peri+position[i][0];q=perj+position[i][1]; > if(picture[p][q]!=space){cout<<"wa"<<endl;goto final;} > peri=p;perj=q; > break; > } > if(i==4){cout<<"wa"<<endl;goto final;} > }else if(st1[k]>='A'&&st1[k]<='Z') > { > for(i=0;i<4;i++) > if(st1[k]==pos[0][i]) > { > p=peri+position[i][0];q=perj+position[i][1]; > if(p!=boxi||q!=boxj){cout<<"wa"<<endl;goto final;} > peri=p;perj=q; > p+=position[i][0];q+=position[i][1]; > if(picture[p][q]!=space){cout<<"wa"<<endl;goto final;} > boxi=p;boxj=q; > break; > } > if(i==4){cout<<"wa"<<endl;goto final;} > }else{cout<<"wa"<<endl;goto final;} > } > if(boxi!=desi||boxj!=desj){cout<<"wa"<<endl;goto final;} > } > cin.getline(st1,2000,'\n');if(!cin){cout<<"wa"<<endl;goto final;} > oup.getline(st2,2000,'\n'); > if(strcmp(st1,st2)){cout<<"wa"<<endl;goto final;} > }while(true); > cin>>ch; > if(cin){cout<<"wa"<<endl;goto final;} > cout<<"ac"<<endl; > final: > inp.close(); > oup.close(); > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator