답안 #54296

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

int n, x0, y0, m;

bool ask(int x, int 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';
}



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

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

void solve(int &x, int &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;
    int a=find1(x0, y0, 1), b=find1(x0, y0, -1);
    m=a-b+1;
    x0=(a+b)/2;
    int 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 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 408 KB Output is correct
2 Correct 2 ms 448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 620 KB Output is correct
2 Correct 2 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 620 KB Output is correct
2 Correct 2 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 620 KB Output is correct
2 Correct 2 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 620 KB Output is correct
2 Correct 3 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 712 KB Output is correct
2 Correct 2 ms 712 KB Output is correct
3 Correct 2 ms 712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 712 KB Output is correct
2 Correct 2 ms 712 KB Output is correct
3 Correct 3 ms 712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 712 KB Output is correct
2 Incorrect 2 ms 712 KB Incorrect
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 712 KB Output is correct
2 Incorrect 2 ms 712 KB Incorrect
3 Halted 0 ms 0 KB -