Submission #633280

# Submission time Handle Problem Language Result Execution time Memory
633280 2022-08-22T04:34:36 Z Spade1 Aliens (IOI07_aliens) C++14
70 / 100
2 ms 208 KB
#include<bits/stdc++.h>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ll long long
#define ld long double
#define st first
#define nd second
#define pb push_back
#define INF INT_MAX
using namespace std;

const int N = 1e5 + 10;

ll find_r(ll l, ll r, ll y) {
    while (l < r) {
        ll mid = (l+r+1)/2;
        cout << "examine " << mid << " " << y << endl;
        string s; cin >> s;
        if (s == "true") l = mid;
        else r = mid-1;
    }
    return l;
}

ll find_l(ll l, ll r, ll y) {
    while (l < r) {
        ll mid = (l+r+1)/2;
        cout << "examine " << mid << " " << y << endl;
        string s; cin >> s;
        if (s == "false") l = mid;
        else r = mid-1;
    }
    return l+1;
}

ll find_u(ll l, ll r, ll x) {
    while (l < r) {
        ll mid = (l+r+1)/2;
        cout << "examine " << x << " " << mid << endl;
        string s; cin >> s;
        if (s == "true") l = mid;
        else r = mid-1;
    }
    return l;
}

void solve() {
    ll n, x, y; cin >> n >> x >> y;
    ll jump, curx, cury, l, r;
    jump = 1;
    curx = x+1;
    l = x, r = x;
    while (1) {
        if (curx > n) {
            r = n;
            break;
        }
        cout << "examine " << curx << " " << y << endl;
        string s; cin >> s;
        if (s == "true") {
            l = curx;
            jump *= 2;
            curx += jump;
        }
        else {
            r = curx-1;
            break;
        }
    }
    ll r_edge = find_r(l, r, y);
    jump = 1;
    curx = x-1;
    l = x, r = x;
    while (1) {
        if (curx < 1) {
            l = 1;
            break;
        }
        cout << "examine " << curx << " " << y << endl;
        string s; cin >> s;
        if (s == "true") {
            r = curx-1;
            jump *= 2;
            curx -= jump;
        }
        else {
            l = curx;
            break;
        }
    }
    ll l_edge = find_l(l, r, y);
    ll M = r_edge - l_edge + 1;
    jump = 1;
    cury = y+1;
    l = y, r = y;
    while (1) {
        if (cury > n) {
            r = n;
            break;
        }
        cout << "examine " << x << " " << cury << endl;
        string s; cin >> s;
        if (s == "true") {
            l = cury;
            jump *= 2;
            cury += jump;
        }
        else {
            r = cury-1;
            break;
        }
    }
    ll u_edge = find_u(l, r, x);
    ll centerx = l_edge+M/2, centery = u_edge - M/2;
    bool u = 0, d = 0, lll = 0, rr = 0;
    if (centerx + 2*M <= n) {
        cout << "examine " << centerx + 2*M << " " << centery << endl;
        string s; cin >> s;
        if (s=="true") rr = 1;
    }
    if (centery - 2*M >= 1) {
        cout << "examine " << centerx << " " << centery - 2*M << endl;
        string s; cin >> s;
        if (s=="true") d = 1;
    }
    if (centerx - 2*M >= 1) {
        cout << "examine " << centerx - 2*M << " " << centery << endl;
        string s; cin >> s;
        if (s=="true") lll = 1;
    }
    if (centery + 2*M <= n) {
        cout << "examine " << centerx << " " << centery + 2*M << endl;
        string s;cin >> s;
        if (s=="true") u = 1;
    }
    if (u&&d&&lll&&rr) {
        cout << "solution " << centerx << " " << centery << endl;
    }
    else if (u&&d&&lll) {
        cout << "solution " << centerx - 2*M << " " << centery << endl;
    }
    else if (u&&d&&rr) {
        cout << "solution " << centerx + 2*M << " " << centery << endl;
    }
    else if (u&&lll&rr) {
        cout << "solution " << centerx << " " << centery + 2*M << endl;
    }
    else if (d&&lll&rr) {
        cout << "solution " << centerx << " " << centery - 2*M << endl;
    }
    else if (d&rr) {
        if (centerx - M < 1 || centery + M > n) {
            cout << "solution " << centerx + 2*M << " " << centery - 2*M << endl;
        }
        else {
            cout << "examine " << centerx - M << " " << centery + M << endl;
            string s; cin >> s;
            if (s == "true") cout << "solution " << centerx + M << " " << centery - M << endl;
            else cout << "solution " << centerx + 2*M << " " << centery - 2*M << endl;
        }
    }
    else if (u&rr) {
        if (centerx - M < 1 || centery - M < 1) {
            cout << "solution " << centerx + 2*M << " " << centery + 2*M << endl;
        }
        else {
            cout << "examine " << centerx - M << " " << centery - M << endl;
            string s; cin >> s;
            if (s == "true") cout << "solution" << centerx + M << " " << centery + M << endl;
            else cout << "solution " << centerx + 2*M << " " << centery + 2*M << endl;
        }
    }
    else if (d&lll) {
        if (centerx + M > n || centery + M > n) {
            cout << "solution " << centerx - 2*M << " " << centery - 2*M << endl;
        }
        else {
            cout << "examine " << centerx + M << " " << centery + M << endl;
            string s; cin >> s;
            if (s == "true") cout << "solution " << centerx - M << " " << centery - M << endl;
            else cout << "solution " << centerx - 2*M << " " << centery - 2*M << endl;
        }
    }
    else if (u&lll) {
        if (centerx + M > n || centery - M < 1) {
            cout << "solution " << centerx - 2*M << " " << centery + 2*M << endl;
        }
        else {
            cout << "examine " << centerx + M << " " << centery - M << endl;
            string s; cin >> s;
            if (s == "true") cout << "solution " << centerx - M << " " << centery + M << endl;
            else cout << "solution " << centerx - 2*M << " " << centery + 2*M << endl;
        }
    }
}

int main() {
//    ios_base::sync_with_stdio(0); cin.tie(NULL);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 2 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 2 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Incorrect 1 ms 208 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 2 ms 208 KB Output is correct