Submission #1051184

#TimeUsernameProblemLanguageResultExecution timeMemory
1051184Dennis_JasonAliens (IOI07_aliens)C++14
0 / 100
1 ms344 KiB
#include <bits/stdc++.h> #define NMAX 200001 #define int long long #define pb push_back #define eb emplace_back #define MOD 1000000007 #define nl '\n' #define INF 1000000007 #define LLONG_MAX 9223372036854775807 #define pii pair<int,int> #define tpl tuple<int,int,int,int> #pragma GCC optimize("O3") using namespace std; ifstream fin("aib.in"); ofstream fout("aib.out"); /* * * ----------------DEMONSTRATION------------------- Steps: 1.Find Xright in given red cell =>M=xr-xl 2.find Xleft in given red cell 3.Find Ydown in given red cell => Yup=Ydown+m 4.find cell_up,cell_right,cell_down,cell_left 5.print Xc,Yc :) ---------------------END------------------------ */ /*-------------Initialize------------*/ int n,x,y; int Xr,Xl,Yu,Yd,Xc,Yc; int Wl,Wr,Wd; int m; int Cl,Cr,Cd,Cu; void find_Wl() { int red=1; int cur=x; int k=0; while(red==1) { cur=x-(1LL << k); if(cur<0) cur=0; Wl=cur; k++; cout.flush()<<"examine "<<cur<<" "<<y<<nl; cout.flush(); string word; cin>>word; if(word=="false") red=0; else red=1; if(red==0) break; } } void find_Wr() { int red=1; int cur=x; int k=0; while(red==1) { cur=x+(1LL << k); if(cur>n) cur=n; Wr=cur; k++; cout.flush()<<"examine "<<cur<<" "<<y<<nl; cout.flush(); string word; cin>>word; if(word=="false") red=0; else red=1; if(red==0) break; } } void find_Xl() { int st=Wl; int dr=Wr; while(st<=dr) { int mid=(st+dr)/2; cout.flush()<<"examine "<<mid<<" "<<y<<nl; cout.flush(); string word; cin>>word; int red; if(word=="false") red=0; else red=1; if(red) { dr=mid-1; Xl=min(mid,Xl); } else st=mid+1; } } void find_Xr() { int st=Wl; int dr=Wr; while(st<=dr) { int mid=(st+dr)/2; cout.flush()<<"examine "<<mid<<" "<<y<<nl; cout.flush(); string word; int red; cin>>word; if(word=="false") red=0; else red=1; if(red) { st=mid+1; Xr=max(mid,Xr); } else dr=mid-1; } } void calc_m() { m=(Xr-Xl+1); } void find_Wd() { int red=1; int cur=y; int k=0; while(red==1) { cur=y-(1LL << k); if(cur<0) cur=0; Wd=cur; k++; cout.flush()<<"examine "<<x<<" "<<cur<<nl; cout.flush(); string word; cin>>word; if(word=="false") red=0; else red=1; if(red==0) break; } } void find_Yd() { int st=Wd; int dr=y; while(st<=dr) { int mid=(st+dr)/2; cout.flush()<<"examine "<<x<<" "<<mid<<nl; cout.flush(); string word; cin>>word; int red; if(word=="false") red=0; else red=1; if(red) { Yd=min(mid,Yd); dr=mid-1; } else st=mid+1; } } void calc_Yu() { Yu=m+Yd-1; } void find_cellUp() { int cur=Yu; Cu=cur; int red=1; int k=1; while(red==1) { cur=Yu+pow(m,k)+1; if(cur>n) cur=n; k++; cout.flush()<<"examine "<<x<<" "<<cur<<nl; cout.flush(); string word; cin>>word; if(word=="false") red=0; else red=1; if(red==0) break; Cu=cur; } } void find_cellDown() { int cur=Yd; int k=1; int red=1; Cd=cur; while(red==1) { cur=Yd-pow(m,k)+1; if(cur<0) cur=0; k++; cout.flush()<<"examine "<<x<<" "<<cur<<nl; cout.flush(); string word; cin>>word; if(word=="false") red=0; else red=1; if(red==0) break; Cd=cur; } } void find_cellLeft() { int cur=Xl; int k=1; int red=1; Cl=cur; while(red==1) { cur=Xl-pow(m,k)+1; if(cur<0) cur=0; k++; cout.flush()<<"examine "<<cur<<" "<<y<<nl; cout.flush(); string word; cin>>word; if(word=="false") red=0; else red=1; if(red==0) break; Cl=cur; } } void find_cellRight() { int cur=Xr; int k=1; int red=1; Cr=cur; while(red==1) { cur=Xr+pow(m,k)+1; if(cur>n) cur=n; k++; cout.flush()<<"examine "<<cur<<" "<<y<<nl; cout.flush(); string word; cin>>word; if(word=="false") red=0; else red=1; if(red==0) break; Cr=cur; } } void find_mid() { if(Cu!=Yu) Cu+=(m-1); if(Cd!=Yd) Cd-=(m-1); if(Cl!=Xl) Cl-=(m-1); if(Cr!=Xr) Cr+=(m-1); int red; //check cout.flush()<<"examine "<<Cl-3<<" "<<Cu+3<<nl; cout.flush(); string word; cin>>word; if(word=="false") red=0; else red=1; if(red) Cu=Cu+3,Cl=Cl-3; // //check right // cout.flush()<<"examine "<<Cr+3<<" "<<Cu+3<<nl; // cout.flush(); // cin>>red; // if(red) // Cr+=3,Cu+=3 Xc=(Cl+Cr)/2; Yc=(Cu+Cd)/2; } void print_solution() { cout.flush()<<"solution "<<Xc<<" "<<Yc<<nl; cout.flush(); } signed main() { // ios_base::sync_with_stdio(false); // cin.tie(NULL); cin>>n>>x>>y; find_Wl(); find_Wr(); find_Xl(); find_Xr(); calc_m(); find_Wd(); find_Yd(); calc_Yu(); find_cellDown(); find_cellLeft(); find_cellRight(); find_cellUp(); find_mid(); print_solution(); return 0; }

Compilation message (stderr)

aliens.cpp:9: warning: "LLONG_MAX" redefined
    9 | #define LLONG_MAX 9223372036854775807
      | 
In file included from /usr/lib/gcc/x86_64-linux-gnu/10/include/limits.h:195,
                 from /usr/lib/gcc/x86_64-linux-gnu/10/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-linux-gnu/10/include/limits.h:34,
                 from /usr/include/c++/10/climits:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:39,
                 from aliens.cpp:1:
/usr/include/limits.h:135: note: this is the location of the previous definition
  135 | #  define LLONG_MAX __LONG_LONG_MAX__
      | 
aliens.cpp: In function 'void find_mid()':
aliens.cpp:325:5: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
  325 |     else
      |     ^~~~
aliens.cpp:327:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
  327 |         if(red)
      |         ^~
#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...