Submission #886633

# Submission time Handle Problem Language Result Execution time Memory
886633 2023-12-12T13:34:26 Z Macker Aliens (IOI07_aliens) C++14
100 / 100
1 ms 600 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()

int n;

bool ask(int x, int y){
    if(x <= 0 || x > n) return false;
    if(y <= 0 || y > n) return false;
    cout << "examine " << x << " " << y << endl;
    string s; cin >> s;
    if(s == "false") return false;
    else return true;
}

int main()
{
    int bx, by; cin >> n >> bx >> by;
    int mid;
    int up = 1, lup = 0;
    while(true){
        if(!ask(bx, by + up)) break;
        lup = up;
        up *= 2;
    }
    up--;
    while(lup < up){
        mid = (up + lup + 1) / 2;
        if(!ask(bx, by + mid)) up = mid - 1;
        else lup = mid;
    }

    int dw = 1, ldw = 0;
    while(true){
        if(!ask(bx, by - dw)) break;
        ldw = dw;
        dw *= 2;
    }
    dw--;
    while(ldw < dw){
        mid = (ldw + dw + 1) / 2;
        if(!ask(bx, by - mid)) dw = mid - 1;
        else ldw = mid;
    }

    int lf = 1, llf = 0;
    while(true){
        if(!ask(bx + lf, by)) break;
        llf = lf;
        lf *= 2;
    }
    lf--;
    while(llf < lf){
        mid = (llf + lf + 1) / 2;
        if(!ask(bx + mid, by)) lf = mid - 1;
        else llf = mid;
    }

    int sz = (up + dw + 1);
    //cout << sz << " " << up << " " << lf << endl;
    by += up - sz / 2;
    bx += lf - sz / 2;

    int mxl = 0;
    for (int i = 1; i < 5; i++)
    {
        if(ask(bx + sz * 2 * i, by)) mxl = i;
        else break;
    }
    int mxu = 0;
    for (int i = 1; i < 5; i++)
    {
        if(ask(bx, by + sz * 2 * i)) mxu = i;
        else break;
    }
    int mxd = 0;
    for (int i = 1; i < 5; i++)
    {
        if(ask(bx, by - sz * 2 * i)) mxd = i;
        else break;
    }
    if(mxd + mxu == 1) {
        if(mxd == 1) by -= sz;
        else by += sz;
        if(mxl == 1) bx += sz;
        else bx -= sz;
    }
    else {
        if(mxd == 2) by -= sz * 2;
        if(mxd == 0) by += sz * 2;
        if(mxl == 2) bx += sz * 2;
        if(mxl == 0) bx -= sz * 2;
    }

    cout << "solution " << bx << " " << by << endl;

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct