Submission #642245

# Submission time Handle Problem Language Result Execution time Memory
642245 2022-09-19T03:09:34 Z andecaandeci Aliens (IOI07_aliens) C++17
0 / 100
3 ms 316 KB
#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;
}

Compilation message

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
1 Incorrect 0 ms 316 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Runtime error 3 ms 208 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -