Kreator14's blog

By Kreator14, history, 4 years ago, In English,

My code is not working. It gives wrong answer on test 25. Someone please help figuring out the problem.

problem: http://codeforces.com/contest/581/problem/D


#include<bits/stdc++.h> #define FOR(i,n) for(i=0;i<n;i++) #define ff first #define ss second #define spurt(i) {if(i==0) cout<<"A"; else if(i==1) cout<<"B"; else cout<<"C";} using namespace std; typedef long long ll; int main() { int i; vector<pair<int,int> > dim(3,make_pair(0,0)); FOR(i,3){ cin>>dim[i].ff; cin>>dim[i].ss; } for(int test=0;test<8;test++){ if(dim[0].ff==dim[1].ff || dim[2].ff==dim[1].ff || dim[0].ff==dim[2].ff){ int x,y,z; if(dim[0].ff == dim[1].ff){ x=0,y=1,z=2; }else if(dim[1].ff == dim[2].ff){ x=1,y=2,z=0; }else { x=2,y=0,z=1; } if(dim[z].ff==dim[x].ff && (dim[x].ff==(dim[x].ss+dim[y].ss+dim[z].ss))){ cout<<dim[x].ff<<endl; for(int i=0;i<dim[x].ss;i++){ for(int j=0;j<dim[x].ff;j++) spurt(x) cout<<endl; } for(int i=0;i<dim[y].ss;i++){ for(int j=0;j<dim[y].ff;j++) spurt(y) cout<<endl; } for(int i=0;i<dim[z].ss;i++){ for(int j=0;j<dim[z].ff;j++) spurt(z) cout<<endl; } return 0; } if(dim[z].ss==(dim[x].ss+dim[y].ss) && dim[z].ss==(dim[z].ff+dim[x].ff)){ cout<<dim[z].ss<<endl; for(int i=0;i<dim[x].ss;i++){ for(int j=0;j<dim[x].ff;j++) spurt(x) for(int j=0;j<dim[z].ff;j++) spurt(z) cout<<endl; } for(int i=0;i<dim[y].ss;i++){ for(int j=0;j<dim[y].ff;j++) spurt(y) for(int j=0;j<dim[z].ff;j++) spurt(z) cout<<endl; } return 0; } } switch(test){ case 0:swap(dim[0].ff,dim[0].ss);break; case 1:swap(dim[1].ff,dim[1].ss);break; case 2:swap(dim[0].ff,dim[0].ss);break; case 3:swap(dim[2].ff,dim[2].ss);break; case 4:swap(dim[1].ff,dim[1].ss);break; case 5:swap(dim[0].ff,dim[0].ss);break; case 6:swap(dim[1].ff,dim[1].ss);break; } } cout<<-1<<endl; return 0; }

Read more »

 
 
 
 
  • Vote: I like it
  • -12
  • Vote: I do not like it