답안 #114168

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
114168 2019-05-31T07:43:58 Z zubec Aliens (IOI07_aliens) C++14
100 / 100
3 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;


bool ask(int x, int y){
    cout << "examine " << x << ' ' << y << endl;
    string s;
    cin >> s;
    return (s == "true");
}

ll crnx, crny, mm;
/*
bool ask(int x, int y){
    if (!(crnx <= x && x <= crnx + mm*5-1 ) || !(crny <= y && y <= crny + mm*5-1))
        return 0;
    ll pr1 = (x-crnx)/mm%2;
    ll pr2 = (y-crny)/mm%2;
    return (pr1^pr2) == 0;
}*/

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);

    crnx = 5;
    crny = 2;
    mm = 3;

    ll n, x0, y0;

    cin >> n >> x0 >> y0;

    /*for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            cout << ask(j, i);
        }
        cout << endl;
    }

    return 0;*/

    ll rgtx0 = 0, lftx0 = 0;

    for (ll i = 1; ; i += i){
        if (x0+i > n || !ask(x0+i, y0)){
            ll l = x0, r = min(n, x0+i);
            while(l < r){
                ll mid = (l+r+1)>>1;
                if (ask(mid, y0))
                    l = mid; else
                    r = mid-1;
            }
            rgtx0 = l;
            break;
        }
    }
    for (ll i = 1; ; i += i){
        if (x0-i <= 0 || !ask(x0-i, y0)){
            ll l = max(1ll, x0-i), r = x0;
            while(l < r){
                ll mid = (l+r)>>1;
                if (ask(mid, y0))
                    r = mid; else
                    l = mid+1;
            }
            lftx0 = l;
            break;
        }
    }
    ll m = rgtx0-lftx0+1;
    ll upy0 = 0;
    for (ll i = 1; ; i += i){
        if (y0-i <= 0 || !ask(lftx0, y0-i)){
            ll l = max(1ll, y0-i), r = y0;
            while(l < r){
                ll mid = (l+r)>>1;
                if (ask(lftx0, mid))
                    r = mid; else
                    l = mid+1;
            }
            upy0 = l;
            break;
        }
    }

    ll up = 0, dwn = 0;
    ll yy = upy0;
    while(yy-2*m >= 1 && ask(lftx0, yy-2*m)){
        ++up;
        yy -= 2*m;
    }
    yy = upy0;
    while(yy+2*m <= n && ask(lftx0, yy+2*m)){
        ++dwn;
        yy += 2*m;
    }

    ll yc = 0;

    if (up == 0 && dwn == 2){
        yc = upy0 + m/2 + m*2;
    } else
    if (up == 1 && dwn == 1){
        yc = upy0 + m/2;
    } else
    if (up == 2 && dwn == 0){
        yc = upy0 + m/2 - m*2;
    } else
    if (up == 0 && dwn == 1){
        yc = upy0 + m/2 + m;
    } else
    if (up == 1 && dwn == 0){
        yc = upy0 + m/2 - m;
    }


    ll lft = 0, rgt = 0;
    ll xx = lftx0;
    while(xx-2*m >= 1 && ask(xx-2*m, upy0)){
        ++lft;
        xx -= 2*m;
    }
    xx = lftx0;
    while(xx+2*m <= n && ask(xx+2*m, upy0)){
        ++rgt;
        xx += 2*m;
    }

    ll xc = 0;

    if (lft == 0 && rgt == 2){
        xc = lftx0 + m/2 + m*2;
    } else
    if (lft == 1 && rgt == 1){
        xc = lftx0 + m/2;
    } else
    if (lft == 2 && rgt == 0){
        xc = lftx0 + m/2 - m*2;
    } else
    if (lft == 0 && rgt == 1){
        xc = lftx0 + m/2 + m;
    } else
    if (lft == 1 && rgt == 0){
        xc = lftx0 + m/2 - m;
    }

    cout << "solution " << xc << ' ' << yc << endl;



}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 304 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 256 KB Output is correct
3 Correct 2 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 256 KB Output is correct