제출 #444694

#제출 시각아이디문제언어결과실행 시간메모리
444694yfhuangAliens (IOI07_aliens)C++17
100 / 100
2 ms328 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back #define eb emplace_back typedef long long ll; typedef pair<int, int> pi; ll n, X0, Y0; bool in(ll x, ll y){ return x >= 1 and x <= n and y >= 1 and y <= n; } bool ask(ll x, ll y){ if(!in(x, y)) return 0; cout << "examine " << x << " " << y << endl; cout.flush(); string s; cin >> s; return s == "true"; } void answer(ll x, ll y){ cout << "solution " << x << " " << y << endl; cout.flush(); } int main(){ ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> n >> X0 >> Y0; ll l = 0, r = 0; for(ll i = 1;;i *= 2){ if(!ask(X0 - i, Y0)){ r = i; break; } } while(l < r){ ll mid = (l + r + 1) / 2; if(ask(X0 - mid, Y0)){ l = mid; }else{ r = mid - 1; } } ll xL = X0 - l; l = 0, r = 0; for(ll i = 1;;i *= 2){ if(!ask(X0 + i, Y0)){ r = i; break; } } while(l < r){ ll mid = (l + r + 1) / 2; if(ask(X0 + mid, Y0)){ l = mid; }else{ r = mid - 1; } } ll xR = X0 + l; ll m = xR - xL + 1; l = 0, r = 0; for(ll i = 1;;i *= 2){ if(!ask(X0, Y0 - i)){ r = i; break; } } while(l < r){ ll mid = (l + r + 1) / 2; if(ask(X0, Y0 - mid)){ l = mid; }else{ r = mid - 1; } } ll yL = Y0 - l; ll yR = yL + m - 1; X0 = xL, Y0 = yL; while(true){ if(ask(X0 - 2 * m, Y0)){ X0 -= 2 * m; continue; } if(ask(X0, Y0 - 2 * m)){ Y0 -= 2 * m; continue; } if(ask(X0 - m, Y0 - m)){ X0 -= m; Y0 -= m; continue; } break; } answer(X0 + 5 * m / 2, Y0 + 5 * m / 2); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

aliens.cpp: In function 'int main()':
aliens.cpp:84:8: warning: unused variable 'yR' [-Wunused-variable]
   84 |     ll yR = yL + m - 1;
      |        ^~
#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...