제출 #1188829

#제출 시각아이디문제언어결과실행 시간메모리
1188829comxddddddAliens (IOI07_aliens)C++20
0 / 100
1 ms408 KiB
#include <bits/stdc++.h>
using namespace std;

int n;

int bsR(int l,int r,int Y){
    int ans = l;
    l++;
    r--;
    while(l <= r){
        int mid = (r - l) / 2 + l;
        if(mid > n){
            r = mid - 1;
            continue;
        }
        cout << "examine " << mid << ' ' << Y << endl;
        string fb;
        cin >> fb;
        if(fb == "true"){
            ans = mid;
            l = mid + 1;
        }
        else{
            r = mid - 1;
        }
    }
    return ans;
}

int bsL(int l,int r,int Y){
    int ans = r;
    l++;
    r--;
    while(l <= r){
        int mid = (r - l) / 2 + l;
        if(mid < 1){
            l = mid + 1;
            continue;
        }
        cout << "examine " << mid << ' ' << Y << endl;
        string fb;
        cin >> fb;
        if(fb == "true"){
            ans = mid;
            r = mid - 1;
        }
        else{
            l = mid + 1;
        }
    }
    return ans;
}

int bsD(int d,int u,int X){
    int ans = u;
    d++;
    u--;
    while(d <= u){
        int mid = (u - d) / 2 + d;
        if(mid < 1){
            d = mid + 1;
            continue;
        }
        cout << "examine " << X << ' ' << mid << endl;
        string fb;
        cin >> fb;
        if(fb == "true"){
            ans = mid;
            u = mid - 1;
        }
        else{
            d = mid + 1;
        }
    }
    return ans;
}

int main(){
    int x,y;
    cin >> n >> x >> y;
    int check = 1;
    string s;
    int checkRight = x;
    int m = 1;
    while(checkRight + check <= n){
        cout << "examine " << checkRight + check << ' ' << y << endl;
        cin >> s;
        if(s != "true"){
            break;
        }
        checkRight += check;
        check *= 2;
    }
    int BSR = bsR(checkRight,checkRight + check,y);
    m += BSR - x;
    int checkLeft = x;
    check = 1;
    while(checkLeft - check >= 1){
        cout << "examine " << checkLeft - check << ' ' << y << endl;
        cin >> s;
        if(s != "true"){
            break;
        }
        checkLeft -= check;
        check *= 2;
    }
    int BSL = bsL(checkLeft - check,checkLeft,y);
    m += x - BSL;
    int checkDown = y;
    check = 1;
    while(checkDown - check >= 1){
        cout << "examine " << x << ' ' << checkDown - check << endl;
        cin >> s;
        if(s != "true"){
            break;
        }
        checkDown -= check;
        check *= 2;
    }
    int BSD = bsD(checkDown,checkDown - check,x);
    int BSU = BSD + m - 1;
    int midx = (BSL + BSR) / 2;
    int midy = (BSD + BSU) / 2;
    s = "true";
    while(s == "true" && midx - (m * 2) >= 1){
        cout << "examine " << midx - (m * 2) << ' ' << midy << endl;
        cin >> s;
        if(s == "true"){
            midx -= m * 2;
        }
    }
    s = "true";
    while(s == "true" && midy - (m * 2) >= 1){
        cout << "examine " << midx << ' ' << midy - (m * 2) << endl;
        cin >> s;
        if(s == "true"){
            midy -= m * 2;
        }
    }
    s = "true";
    while(s == "true" && midx - m >= 1 && midy - m >= 1){
        cout << "examine " << midx - m << ' ' << midy - m << endl;
        cin >> s;
        if(s == "true"){
            midx -= m;
            midy -= m;
        }
    }
    cout << "solution " << midx + (m * 2) << ' ' << midy + (m * 2) << endl;
}
#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...