Submission #260411

#TimeUsernameProblemLanguageResultExecution timeMemory
260411stefantagaTower Defense (CEOI19_towerdefense)C++14
53 / 100
1 ms416 KiB
#include <bits/stdc++.h> using namespace std; int x,y,x2,y2,dist,nr,sensx,sensy,val,i; int main() { cin>> x2 >> y2; cin>> x >> y; cin>>nr; dist=abs(x-x2)+abs(y-y2); if (dist>nr) { cout<<"impossible"; return 0; } if (dist==nr) { cout<<"0"; return 0; } if (dist==1) { cout<<"impossible"; return 0; } if ((nr-dist)%2==1) { cout<<"impossible"; return 0; } if (x!=x2&&y!=y2) { if (x<x2) { sensx=-1; } else { sensx=1; } if (y<y2) { sensy=-1; } else { sensy=1; } if (dist==2&&nr<dist+4) { cout<<"impossible"; return 0; } if (dist==2) { val=(nr-dist-4)/2+1; } else { val=(nr-dist)/2; } cout<<val*2<<'\n'; for (i=1;i<=val;i++) { cout<<x2+sensx*i<<" "<<y2<<'\n'; cout<<x2<<" "<<y2+sensy*i<<'\n'; } } else if (y==y2) { if (x<x2) { sensx=-1; } else { sensx=1; } val=(nr-dist)/2; cout<<2*(val-1)+1<<'\n'; cout<<x2+sensx<<" "<<y<<'\n'; for (i=2;i<=val;i++) { cout<<x2+sensx<<" "<<y-i+1<<'\n'; cout<<x2+sensx<<" "<<y+i-1<<'\n'; } } else if (x==x2) { if (y<y2) { sensy=-1; } else { sensy=1; } val=(nr-dist)/2; cout<<2*(val-1)+1<<'\n'; cout<<x2<<" "<<y+sensy<<'\n'; for (i=2;i<=val;i++) { cout<<x2-i+1<<" "<<y+sensy<<'\n'; cout<<x2+i-1<<" "<<y+sensy<<'\n'; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...