Submission #502093

# Submission time Handle Problem Language Result Execution time Memory
502093 2022-01-05T09:25:58 Z tabr Aliens (IOI07_aliens) C++17
30 / 100
2 ms 320 KB
#include <bits/stdc++.h>
using namespace std;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long n, x0, y0;
    cin >> n >> x0 >> y0;
    x0--, y0--;
    auto ask = [&](long long x, long long y) {
        if (max(x, y) >= n || min(x, y) < 0) {
            return false;
        }
        cout << "examine " << x + 1 << " " << y + 1 << endl;
        string s;
        cin >> s;
        return (s == "true");
    };
    long long r;
    {
        long long t = 2;
        while (ask(x0 + t - 1, y0)) {
            t <<= 1;
        }
        long long lo = x0;
        long long hi = x0 + t - 1;
        while (hi - lo > 1) {
            long long mid = (hi + lo) / 2;
            if (ask(mid, y0)) {
                lo = mid;
            } else {
                hi = mid;
            }
        }
        r = lo;
    }
    long long l;
    {
        long long t = 2;
        while (ask(x0 - t + 1, y0)) {
            t <<= 1;
        }
        long long lo = x0 - t + 1;
        long long hi = x0;
        while (hi - lo > 1) {
            long long mid = (hi + lo) / 2;
            if (ask(mid, y0)) {
                hi = mid;
            } else {
                lo = mid;
            }
        }
        l = hi;
    }
    x0 = (l + r) / 2;
    long long m = r - l + 1;
    {
        long long lo = y0;
        long long hi = y0 + m;
        while (hi - lo > 1) {
            long long mid = (hi + lo) / 2;
            if (ask(x0, mid)) {
                lo = mid;
            } else {
                hi = mid;
            }
        }
        y0 = lo - m / 2;
    }
    if (ask(x0 + 4 * m, y0)) {
        x0 += 2 * m;
    } else if (ask(x0 - 4 * m, y0)) {
        x0 -= 2 * m;
    } else {
        int a = ask(x0 + 2 * m, y0);
        int b = ask(x0 - 2 * m, y0);
        if (a && !b) {
            x0 += m;
        } else if (!a && b) {
            x0 -= m;
        }
    }
    if (ask(x0, y0 + 4 * m)) {
        y0 += 2 * m;
    } else if (ask(x0, y0 - 4 * m)) {
        y0 -= 2 * m;
    } else {
        int a = ask(x0, y0 + 2 * m);
        int b = ask(x0, y0 - 2 * m);
        if (a && !b) {
            y0 += m;
        } else if (!a && b) {
            y0 -= m;
        }
    }
    cout << "solution " << x0 + 1 << " " << y0 + 1 << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Incorrect 0 ms 200 KB Incorrect
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Incorrect 1 ms 200 KB Incorrect
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Incorrect 0 ms 200 KB Incorrect
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Incorrect 1 ms 200 KB Incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 200 KB Output is correct
2 Incorrect 1 ms 200 KB Incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 320 KB Output is correct
2 Correct 2 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 2 ms 200 KB Output is correct
3 Incorrect 2 ms 200 KB Incorrect