Submission #828361

#TimeUsernameProblemLanguageResultExecution timeMemory
828361vjudge1Aliens (IOI07_aliens)C++17
30 / 100
3 ms300 KiB
#include<bits/stdc++.h> #define ll long long using namespace std; ll N, X0, Y0, M; ll x,y; ll up, down, lef, righ; string torf; bool cek=true; bool cevrypos(int fx, int fy) { ll tanx, tany; bool fourwi[5]={false}; //tanya atasnya tany = fy+2*M+M/2; tanx = fx; if(tany>=1 && tany<=N && tanx>=1 && tanx<=N) { cout << "examine " << tanx << " " << tany << endl; cin >> torf; if(torf=="true") { fourwi[1] = true; } } if(fourwi[1]==false) return false; //tanya bawahnya tany = fy-2*M-M/2; tanx = fx; if(tany>=1 && tany<=N && tanx>=1 && tanx<=N) { cout << "examine " << tanx << " " << tany << endl; cin >> torf; if(torf=="true") { fourwi[2] = true; } } if(fourwi[2]==false) return false; //tanya kirinya tanx = fx-2*M-M/2; tany = fy; if(tanx>=1 && tanx<=N && tany>=1 && tany<=N) { cout << "examine " << tanx << " " << tany << endl; cin >> torf; if(torf=="true") { fourwi[3] = true; } } if(fourwi[3]==false) return false; //tanya kanannya tanx = fx+2*M+M/2; tany = fy; if(tanx>=1 && tanx<=N && tany>=1 && tany<=N) { cout << "examine " << tanx << " " << tany << endl; cin >> torf; if(torf=="true") { fourwi[4] = true; } } if(fourwi[4]==false) return false; return true; } int main() { cin >> N >> X0 >> Y0; up = Y0; down = Y0; righ = X0; lef = X0; x = X0; y = Y0; //cek batas atas while(cek==true) { y+=2; if(y<=N) { cout << "examine " << x << " " << y << endl; cin >> torf; if(torf=="true") { cek=true; up = y; } else { cout << "examine " << x << " " << y-1 << endl; cin >> torf; if(torf=="true") { up = y-1; } cek=false; break; } } else if(y-1 <= N) { cout << "examine " << x << " " << y-1 << endl; cin >> torf; if(torf=="true") { up = y-1; } break; } else { break; } } cek = true; x = X0; y = Y0; //cek batas bawah while(cek==true) { y-=2; if(y>=1) { cout << "examine " << x << " " << y << endl; cin >> torf; if(torf=="true") { cek=true; down=y; } else { cout << "examine " << x << " " << y+1 << endl; cin >> torf; if(torf=="true") { down = y+1; } cek=false; break; } } else if(y+1 >= 1) { cout << "examine " << x << " " << y+1 << endl; cin >> torf; if(torf=="true") { down = y+1; } break; } else { break; } } cek=true; x = X0; y = Y0; //cek batas kanan while(cek==true) { x+=2; if(x<=N) { cout << "examine " << x << " " << y << endl; cin >> torf; if(torf=="true") { cek=true; righ = x; } else { cout << "examine " << x-1 << " " << y << endl; cin >> torf; if(torf=="true") { righ = x-1; } cek=false; break; } } else if(x-1 <= N) { cout << "examine " << x-1 << " " << y << endl; cin >> torf; if(torf=="true") { righ = x-1; } break; } else { break; } } cek=true; x = X0; y = Y0; //cek batas kiri while(cek==true) { x-=2; if(x>=1) { cout << "examine " << x << " " << y << endl; cin >> torf; if(torf=="true") { cek=true; lef = x; } else { cout << "examine " << x+1 << " " << y << endl; cin >> torf; if(torf=="true") { lef = x+1; } cek=false; break; } } else if(x+1 >= 1) { cout << "examine " << x+1 << " " << y << endl; cin >> torf; if(torf=="true") { lef = x+1; } break; } else { break; } } M = abs(up-Y0)+abs(Y0-down)+1; ll finx, finy; bool midofmid; //seandainya di square 1 finx = righ+M+(M/2-1); finy = down-M-(M/2+1); midofmid = cevrypos(finx, finy); if(midofmid) { cout << "solution " << finx << " " << finy << endl; return 0; } //seandainya di square 2 finx = lef+(M/2); finy = down-M-(M/2+1); midofmid = cevrypos(finx, finy); if(midofmid) { cout << "solution " << finx << " " << finy << endl; return 0; } //seandainya di square 3 finx = lef-M-(M/2+1); finy = down-M-(M/2+1); midofmid = cevrypos(finx, finy); if(midofmid) { cout << "solution " << finx << " " << finy << endl; return 0; } //seandainya di square 4 finx = righ+(M/2+1); finy = down-(M/2+1); midofmid = cevrypos(finx, finy); if(midofmid) { cout << "solution " << finx << " " << finy << endl; return 0; } //seandainya square 5 finx = lef-(M/2+1); finy = down-(M/2+1); midofmid = cevrypos(finx, finy); if(midofmid) { cout << "solution " << finx << " " << finy << endl; return 0; } //seandainya di square 6 finx = righ+M+(M/2+1); finy = up-M/2; midofmid = cevrypos(finx, finy); if(midofmid) { cout << "solution " << finx << " " << finy << endl; return 0; } //seandainya di square 7 finx = lef+M/2; finy = up-M/2; midofmid = cevrypos(finx, finy); if(midofmid) { cout << "solution " << finx << " " << finy << endl; return 0; } //seandainya di square 8 finx = lef-M-(M/2+1); finy = up-M/2; midofmid = cevrypos(finx, finy); if(midofmid) { cout << "solution " << finx << " " << finy << endl; return 0; } //seandainya di square 9 finx = righ+(M/2+1); finy = up+(M/2+1); midofmid = cevrypos(finx, finy); if(midofmid) { cout << "solution " << finx << " " << finy << endl; return 0; } //seandainya di square 10 finx = lef-(M/2+1); finy = up+(M/2+1); midofmid = cevrypos(finx, finy); if(midofmid) { cout << "solution " << finx << " " << finy << endl; return 0; } //seandainya di square 11 finx = righ+M+(M/2+1); finy = up+M+(M/2+1); midofmid = cevrypos(finx, finy); if(midofmid) { cout << "solution " << finx << " " << finy << endl; return 0; } //seandainya di square 12 finx = lef+(M/2); finy = up+M+(M/2+1); midofmid = cevrypos(finx, finy); if(midofmid) { cout << "solution " << finx << " " << finy << endl; return 0; } //seandainya square 13 finx = lef-M-(M/2+1); finy = up+M+(M/2+1); midofmid = cevrypos(finx, finy); if(midofmid) { cout << "solution " << finx << " " << finy << endl; return 0; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...