제출 #642245

#제출 시각아이디문제언어결과실행 시간메모리
642245andecaandeciAliens (IOI07_aliens)C++17
0 / 100
3 ms316 KiB
#include <bits/stdc++.h> using namespace std; int n, m, xs, ys; int d[] = {-4, -3, -2, -1, 1, 2, 3, 4}; bool ask(int x, int y){ cout << "examine " << x << " " << y << endl; string s; cin >> s; return (s == "true"); } pair<int, int>f(){ int R = xs, L = xs, T = ys, B = ys; while(R + 1 <= n && ask(R + 1, ys)) R++; while(L - 1 >= 1 && ask(L - 1, ys)) L--; while(T + 1 <= n && ask(xs, T + 1)) T++; int M = (R - L + 1); B = T - M + 1; m = M; return {L + M/2, T - M/2}; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> xs >> ys; auto [x, y] = f(); int xl = x, xr = x, yl = y, yr = y; int cnt = 1; for(int i = 0; i < 8; i++){ if(x + d[i]*m >= 1 && x + d[i]*m <= n && y + d[i]*m >= 1 && y + d[i]*m <= n){ if(ask(x + d[i]*m, y + d[i]*m)){ cnt++; if(x + d[i]*m < xl){ xl = x + d[i]*m; yl = y + d[i]*m; } if(x + d[i]*m > xr){ xr = x + d[i]*m; yr = y + d[i]*m; } } } } x = (xl + xr)/2; y = (yl + yr)/2; if(cnt == 1){ if(x + m <= n && y + m <= n && ask(x + m, y + m)){ x += 2*m; y += 2*m; } else{ x -= 2*m; y -= 2*m; } } else if(cnt == 3){ if(x + 2*m <= n && y + 2*m <= n && ask(x + m, y + m) && ask(x + 2*m, y + 2*m)){ x += m; y += m; } else{ x -= m; y -= m; } } cout << "solution " << x << " " << y << endl; return 0; }

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

aliens.cpp: In function 'std::pair<int, int> f()':
aliens.cpp:15:33: warning: variable 'B' set but not used [-Wunused-but-set-variable]
   15 |     int R = xs, L = xs, T = ys, B = ys;
      |                                 ^
#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...