Submission #1190414

#TimeUsernameProblemLanguageResultExecution timeMemory
1190414amm_ouxAliens (IOI07_aliens)C++20
30 / 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 ;

    bool response = true;
    string res ;
    
    

    while (response && X+Pow[j] < N +1 ){
        cout <<  "examine " << X+Pow[j] << " " << Y << flush << endl ;
        cin >> res ;
        if (res == "true") { j++ ; }
        else {response = 0 ;}
     }
     
     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 ;





     response = 1 ; j = 1 ;
     while (response && X-Pow[j] > 0 ){
        cout <<  "examine " << X-Pow[j] << " " << Y << flush << endl ;
        cin >> res ;
        if (res == "true") {  j++ ; }
        else {response = 0 ;}
     }
     
     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 = Xf + (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 ;






     response = 1 ; j = 1 ;
     while (response && Y+Pow[j] < N+1 ){
        cout <<  "examine " << X<< " " << Y+Pow[j] << flush << endl ;
        cin >> res ;
        if (res == "true") {  j++ ; }
        else {response = 0 ;}
     }
     
     Ypr = Y+Pow[j-1] ; Yf = min (Y+Pow[j] , N ) ;

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

     } 


     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 = 5 ;
     int sxpos = 5 ;



     for (int i = 0 ; i < 4 ; i++) {
        if (Xd + (4-i)*M > N ) continue ;
        else {
            cout <<  "examine " << Xd + (4-i)*M << " " << Y << endl ; cin >> res ;
            if (res == "true") {  sxpos = i+1 ; break ;}
        }
     }

     for (int i = 0 ; i < 4 ; i++) {
        if (Yu + (4-i)*M > N ) continue ;
        else {
            cout <<  "examine " << X << " " << Yu + (4-i)*M << endl ; cin >> res ;
            if (res == "true") {  sypos = i+1 ; break ;}
        }
     }

     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...