이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |