Submission #792738

# Submission time Handle Problem Language Result Execution time Memory
792738 2023-07-25T08:25:48 Z Warinchai Aliens (IOI07_aliens) C++14
0 / 100
1 ms 288 KB
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,x,y;
    cin>>n>>x>>y;
    int lm=1,rm=1;
    while(lm+x<=n){
        cout<<"examine "<<lm+x<<" "<<y<<endl;
        bool hv;
        cin>>hv;
        if(hv==false){
            break;
        }
        lm=lm*2;
    }
    //cout<<"lm:"<<lm<<endl;
    int en=lm+x;
    int st=x+(lm/2);
    int ansr=0;
    if(lm+x>n){
        en=n;
    }
    while(st<=en){
        int m=(st+en)/2;
        cout<<"examine "<<m<<" "<<y<<endl;
        bool hv;
        cin>>hv;
        if(hv){
            ansr=m;
            st=m+1;
        }else{
            en=m-1;
        }
    }
    //cout<<"ansr:"<<ansr<<endl;
    //end
    while(x-rm>=1){
        cout<<"examine "<<x-rm<<" "<<y<<endl;
        bool hv;
        cin>>hv;
        if(hv==false){
            break;
        }
        rm=rm*2;
    }
    //cout<<"rm:"<<rm<<endl;
    st=x-rm;
    en=x-(rm/2);
    int ansl=0;
    if(x-rm<1){
        st=1;
    }
    while(st<=en){
        int m=(st+en)/2;
        cout<<"examine "<<m<<" "<<y<<endl;
        bool hv;
        cin>>hv;
        if(hv){
            ansl=m;
            en=m-1;
        }else{
            st=m+1;
        }
    }
    //cout<<"ansl:"<<ansl<<endl;
    int sz=(ansr-ansl+1);
    //cout<<"sz:"<<sz<<endl;
    int stx,sty;
    st=0,en=sz;
    while(st<=en){
        int m=(st+en)/2;
        if(ansl-m*sz<1){
            en=m-1;
            continue;
        }
        int sq=ansl-m*sz;
        cout<<"examine "<<sq<<" "<<y<<endl;
        int hv;
        cin>>hv;
        if(hv==true){
            stx=sq;
            st=m+1;
        }else{
            en=m-1;
        }
    }
    //cout<<"starting of x"<<stx<<endl;
    st=y-sz,en=y;
    if(st<1){
        st=1;
    }
    int ansu;
    while(st<=en){
        int m=(st+en)/2;
        cout<<"examine "<<x<<" "<<m<<endl;
        bool hv;
        cin>>hv;
        if(hv){
            ansu=m;
            en=m-1;
        }else{
            st=m+1;
        }
    }
    //cout<<"start of little square y:"<<ansu<<endl;
    st=0,en=sz;
    while(st<=en){
        int m=(st+en)/2;
        if(ansu-m*sz<1){
            en=m-1;
            continue;
        }
        int sq=ansu-m*sz;
        cout<<"examine "<<x<<" "<<sq<<endl;
        int hv;
        cin>>hv;
        if(hv==true){
            sty=sq;
            st=m+1;
        }else{
            en=m-1;
        }
    }
    //cout<<"start of y:"<<sty<<endl;
    int add;
    add=(sz)/2;
    add=add*sz*2;
    add+=sz/2;
    cout<<"solution "<<stx+add<<" "<<sty+add<<endl;
}

Compilation message

aliens.cpp: In function 'int main()':
aliens.cpp:129:33: warning: 'stx' may be used uninitialized in this function [-Wmaybe-uninitialized]
  129 |     cout<<"solution "<<stx+add<<" "<<sty+add<<endl;
      |                                 ^~~
aliens.cpp:129:42: warning: 'sty' may be used uninitialized in this function [-Wmaybe-uninitialized]
  129 |     cout<<"solution "<<stx+add<<" "<<sty+add<<endl;
      |                                          ^~~
aliens.cpp:109:16: warning: 'ansu' may be used uninitialized in this function [-Wmaybe-uninitialized]
  109 |         if(ansu-m*sz<1){
      |            ~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 288 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -