제출 #1194044

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

using namespace std ;

using ll = long long ;

#define vll vector<ll>

#define vvll vector<vll>

ll Pow[33] ;

void powsof2 (){
    ll p = 1 ;
    Pow[0] = 0 ;
    Pow[1] = 1 ;

    for (int i = 2 ; i < 33 ; i++){
        p*=2 ;
        Pow[i] = p ;
    }
}



void solve (){

    powsof2() ;

    ll N ,X , Y , M;

    ll Xd = -1 ; ll Xg = -1 ; ll Yu = -1 ;
    ll Xf , Yf , Xpr , Ypr;
    int j = 1 ;

    cin >> N >> X >> Y ;

    string res ;



    while (X+Pow[j] < N +1 ){
        cout <<  "examine " << X+Pow[j] << " " << Y << flush << endl ;
        cin >> res ;
        if (res == "true") j++ ;
        else break ;
     }

     Xpr = X+Pow[j-1] ; Xf = min (N , X+Pow[j] ) ;

     if (X+Pow[j] > N ) {
            if (Xpr==N) {Xd = N ; }
     else
        {
            cout <<  "examine " << N << " " << Y << flush << endl ; cin >> res ;
            if (res == "true") {Xd = N ; }
        }

     }




     while (Xd < 0 && Xf - Xpr > 1) {
        ll mid = Xpr + (Xf - Xpr)/2 ;
        cout <<  "examine " << mid << " " << Y << flush << endl ;
        cin >> res ;
        if (res == "true") {  Xpr = mid ; }
        else {Xf = mid ;}
     } if (Xd < 0) Xd = Xpr ;




    j = 1 ;
     while ( X-Pow[j] > 0 ){
        cout <<  "examine " << X-Pow[j] << " " << Y << flush << endl ;
        cin >> res ;
        if (res == "true") {  j++ ; }
        else break ;
     }

     Xpr = X-Pow[j-1] ; Xf = max (N-N+1 , X-Pow[j] ) ;

     if (X-Pow[j] < 1) {
            if (Xpr == 1) {Xg = 1 ; }
     else {
            cout <<  "examine " << 1 << " " << Y << flush << endl ; cin >> res ;
        if (res == "true") {Xg = 1 ;}

     }
     }


     while (Xg < 0 && Xpr - Xf > 1) {
        ll mid = Xpr - (Xpr - Xf)/2 ;
        cout <<  "examine " << mid << " " << Y << flush << endl ;
        cin >> res ;
        if (res == "true") {  Xpr = mid ; }
        else {Xf = mid ;}
     } if (Xg < 0) Xg = Xpr ;


     M = Xd - Xg + 1 ;








     Ypr = Y ; Yf = min (Y+M-1 , N ) ;

     if (Ypr == N) Yu = N ;
     else {
        cout <<  "examine " << X << " " << Yf << flush << endl ;
        cin >> res ;
        if (res == "true") {  Yu = Yf ; }
     }



     while (Yu < 0 && Yf - Ypr > 1) {
        ll mid = Ypr + (Yf - Ypr)/2 ;
        cout <<  "examine " << X << " " << mid << flush << endl ;
        cin >> res ;
        if (res == "true") {  Ypr = mid ; }
        else {Yf = mid ;}
     } if (Yu < 0) Yu = Ypr ;




     int sypos = -1 ;
     int sxpos = -1 ;



        if (sxpos < 0 && Xd + (4)*M < N+1 ) {
            cout <<  "examine " << Xd + (4)*M << " " << Y << flush  << endl ; cin >> res ;
            if (res == "true") sxpos = 1 ;
        }

        if (sxpos < 0 && Xd + (2)*M < N+1 ){
            cout <<  "examine " <<  Xd + (2)*M << " " << Y << flush  << endl ; cin >> res ;
            if (res == "true") {
                    sxpos = 2 ;
                if (Xd - (2)*M > 0){
                    cout <<  "examine " <<  Xd - (2)*M << " " << Y << flush  << endl ; cin >> res ;
                    if (res == "true") sxpos = 3 ;
                }
            }
        }


        if (sxpos < 0 && Xd - (4)*M > 0 ){
            cout <<  "examine " << Xd - (4)*M << " " << Y << flush  << endl ; cin >> res ;
            if (res == "true") sxpos = 5 ;
        }
        if (sxpos < 0) sxpos = 4 ;



     if ( sxpos == 1 || sxpos == 3 || sxpos == 5){
        if (sypos < 0 && Yu + (4)*M < N+1 ) {
            cout <<  "examine " << X << " " << Yu + (4)*M  << flush  << endl ; cin >> res ;
            if (res == "true") sypos = 1 ;
        }
        if (sypos < 0 && Yu + (2)*M < N+1 ) {
            cout <<  "examine " << X << " " << Yu + (2)*M  << flush  << endl ; cin >> res ;
            if (res == "true") sypos = 3 ;
        }
        if (sypos < 0  ) {sypos = 5 ;}
     }


     else {

            if (sypos < 0 && Yu + (2)*M < N+1 ) {
            cout <<  "examine " << X << " " << Yu + (2)*M  << flush  << endl ; cin >> res ;
            if (res == "true") sypos = 2 ;
        }
        if (sypos < 0  ) {sypos = 4 ;}

     }

     cout << "solution " << Xd + (3-sxpos)*M - M/2 << " " << Yu + (3-sypos)*M - M/2 << flush << endl;




}


int main (){
    ll t = 1 ;
    //ios :: sync_with_stdio(false) ; cin.tie(0);
    while (t--)
        solve();
}
#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...