제출 #1339132

#제출 시각아이디문제언어결과실행 시간메모리
1339132po_rag526Aliens (IOI07_aliens)C++17
0 / 100
1 ms452 KiB
#include <bits/stdc++.h>

using namespace std;

void solve(){
    int n, x0, y0;
    cin >> n >> x0 >> y0;
    int r = 0;
    vector<bool> in = {true};
    int i = 0;

    int z = (1<<30);
    for (int b = z; b >= 0; b >>= 1){
        if (x0+r+b <= n){
            cout << "examine " << x0+r+b << " " << y0 << endl;
            string temp;
            cin >> temp;
            if (temp == "true") in.push_back(true);
            else in.push_back(false);
        }
        else in.push_back(false);
        i++;
        if (in[i]) r += b;
    }
    int l = 0;
    for (int b = z; b >= 0; b >>= 1){
        if (x0-l-b > 0){
            cout << "examine " << x0-l-b << " " << y0 << endl;
            string temp;
            cin >> temp;
            if (temp == "true") in.push_back(true);
            else in.push_back(false);
        }
        else in.push_back(false);
        i++;
        if (in[i]) l += b;
    }
    int m = l+r+1;
    cout << "examine " << x0-l+(m/2) << " " << y0 << endl;
    string temp;
    cin >> temp;
    if (temp == "true") in.push_back(true);
    else in.push_back(false);
    i++;
    if (in[i]){
        cout << "examine " << x0-l+(m/5)+1 << " " << y0 << endl;
        string temp;
        cin >> temp;
        if (temp == "true") in.push_back(true);
        else in.push_back(false);
        i++;
        if (!in[i]){
            m /= 5;
            if (l <= x0-m) l += 2*m;
            if (r >= x0+m) r -= 2*m;
            if (l <= x0-m) l += 2*m;
            if (r >= x0+m) r -= 2*m;
        }
    }
    else{
        m /= 3;
        if (l <= x0-m) l += 2*m;
        if (r >= x0+m) r -= 2*m;
    }
    int u = 0;
    in[i] = true;
    for (int b = z; b >= 0; b >>= 1){
        if (y0+u+b <= n){
            cout << "examine " << x0 << " " << y0+u+b << endl;
            string temp;
            cin >> temp;
            if (temp == "true") in.push_back(true);
            else in.push_back(false);
        }
        else in.push_back(false);
        i++;
        if (in[i]) u += b;
    }
    u %= m;
    int d = m-u-1;
    int cx0 = x0-l+(m/2), cy0 = y0-d+(m/2);
    // cout << cx0 << " " << cy0 << endl;
    vector<bool> inc;
    for (int y = m; y >= -m; y -= 2*m){
        for (int x = -m; x <= m; x += 2*m){
            if (cx0+x <= n && cx0+x > 0 && cy0+y <= n && cy0+y > 0){
                cout << "examine " << cx0+x << " " << cy0+y << endl;
                string temp;
                cin >> temp;
                if (temp == "true") inc.push_back(true);
                else inc.push_back(false);
            }
            else inc.push_back(false);
        }
    }
    int xc = cx0, yc = cy0;
    if (inc[0] && inc[1] && inc[2] && inc[3]){
        vector<bool> inb;
        for (int x = -m; x <= m; x += 2*m){
            if (cx0+2*x <= n && cx0+2*x > 0){
                cout << "examine " << cx0+2*x << " " << cy0 << endl;
                string temp;
                cin >> temp;
                if (temp == "true") inb.push_back(true);
                else inb.push_back(false);
            }
            else inb.push_back(false);
        }
        for (int y = m; y >= -m; y -= 2*m){
            if (cy0+2*y <= n && cy0+2*y > 0){
                cout << "examine " << cx0 << " " << cy0+2*y << endl;
                string temp;
                cin >> temp;
                if (temp == "true") inb.push_back(true);
                else inb.push_back(false);
            }
            else inb.push_back(false);
        }
        int xc = cx0, yc = cy0;
        if (inb[0]) xc -= m;
        if (inb[1]) xc += m;
        if (inb[2]) yc += m;
        if (inb[3]) yc -= m;
        cout << "solution " << xc << " " << yc << endl;
        return;
    }
    else {
        if (inc[0]){
            xc -= 2*m;
            yc += 2*m;
        }
        if (inc[1]){
            xc += 2*m;
            yc += 2*m;
        }
        if (inc[2]){
            xc -= 2*m;
            yc -= 2*m;
        }
        if (inc[3]){
            xc += 2*m;
            yc -= 2*m;
        }
        if (xc == cx0-4*m) xc += 2*m;
        if (xc == cx0+4*m) xc -= 2*m;
        if (yc == cy0-4*m) yc += 2*m;
        if (yc == cy0+4*m) yc -= 2*m;
        cout << "solution " << xc << " " << yc << endl;
        return;
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    // int t;
    // cin >> t;
    // while (t--) solve();
    solve();
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...