답안 #54297

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
54297 2018-07-03T06:16:52 Z 노영훈(#1472) Aliens (IOI07_aliens) C++11
100 / 100
3 ms 700 KB
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=500010, inf=2e9;

ll n, x0, y0, m;

bool ask(ll x, ll y){
    if(x<1 || n<x || y<1 || n<y) return false;
    cout<<"examine "<<x<<' '<<y<<endl;
    char S[10]; cin>>S;
    return S[0]=='t';
}



ll find1(ll x, ll y, ll dx){
    ll pw=1;
    while(ask(x+dx*pw, y)) pw*=2;
    if(pw==1) return x;
    // [x+pw/2 ~ x+pw)
    ll s=pw/2, e=pw-1;
    while(s<e){
        ll m=(s+e+1)/2;
        if(ask(x+m*dx, y)) s=m;
        else e=m-1;
    }
    return x+s*dx;
}

ll find2(ll x, ll y, ll dy){
    ll s=0, e=m;
    while(s<e){
        ll m=(s+e+1)/2;
        if(ask(x,y+m*dy)) s=m;
        else e=m-1;
    }
    return y+s*dy;
}

void solve(ll &x, ll &y){
    bool A[4], B[4];
    // A
    //   1 
    // 2   0
    //   3

    // B
    // 1   0
    // 
    // 2   3
    A[0]=ask(x+2*m, y);
    A[1]=ask(x, y+2*m);
    A[2]=ask(x-2*m, y);
    A[3]=ask(x, y-2*m);
    B[0]=ask(x+m,y+m);
    B[1]=ask(x-m,y+m);
    B[2]=ask(x-m,y-m);
    B[3]=ask(x+m,y-m);
    if(B[0]&&B[1]&&B[2]&&B[3]){
        if(!A[0]) x-=m;
        if(!A[1]) y-=m;
        if(!A[2]) x+=m;
        if(!A[3]) y+=m;
    }
    else{
        if(!A[0]) x-=2*m;
        if(!A[1]) y-=2*m;
        if(!A[2]) x+=2*m;
        if(!A[3]) y+=2*m;
    }
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n>>x0>>y0;
    ll a=find1(x0, y0, 1), b=find1(x0, y0, -1);
    m=a-b+1;
    x0=(a+b)/2;
    ll c=find2(x0, y0, 1), d=find2(x0, y0, -1);
    y0=(c+d)/2;

    solve(x0, y0);
    cout<<"solution "<<x0<<' '<<y0<<endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 3 ms 420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 2 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 2 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 2 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 3 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 2 ms 600 KB Output is correct
3 Correct 2 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 2 ms 600 KB Output is correct
3 Correct 2 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 600 KB Output is correct
2 Correct 3 ms 600 KB Output is correct
3 Correct 3 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 2 ms 700 KB Output is correct
3 Correct 2 ms 700 KB Output is correct