Submission #987288

# Submission time Handle Problem Language Result Execution time Memory
987288 2024-05-22T13:57:20 Z huutuan Aliens (IOI07_aliens) C++14
100 / 100
2 ms 504 KB
#include<bits/stdc++.h>

using namespace std;

#define int long long

int n;

bool check(int x, int y){
   if (x<1 || y<1 || x>n || y>n) return 0;
   cout << "examine " << x << ' ' << y << endl;
   string s; cin >> s;
   return s[0]=='t';
}

int32_t main(){
   ios_base::sync_with_stdio(false);
   cin.tie(nullptr);
   int x0, y0;
   cin >> n >> x0 >> y0;
   int lx, rx;
   {
      int l=x0, r=2e9;
      while (l<=r){
         int mid=(l+r)>>1;
         if (check(mid, y0) && check((x0+mid)>>1, y0) && check((x0+((x0+mid)>>1))>>1, y0)) l=mid+1;
         else r=mid-1;
      }
      rx=r;
   }
   {
      int l=0, r=x0;
      while (l<=r){
         int mid=(l+r)>>1;
         if (check(mid, y0) && check((x0+mid)>>1, y0) && check((x0+((x0+mid)>>1))>>1, y0)) r=mid-1;
         else l=mid+1;
      }
      lx=l;
   }
   int m=rx-lx+1;
   int mx=(lx+rx)>>1;
   int ly, ry;
   {
      int l=y0, r=y0+m;
      while (l<=r){
         int mid=(l+r)>>1;
         if (check(x0, mid)) l=mid+1;
         else r=mid-1;
      }
      ry=r;
   }
   ly=ry-m+1;
   int my=(ly+ry)>>1;
   for (int i=-2; i<=2; ++i) for (int j=-2; j<=2; ++j) if ((i+j)%2==0){
      int tx=mx+m*i, ty=my+m*j;
      bool ans=1;
      for (int k=-2; k<=2; ++k) for (int l=-2; l<=2; ++l) if ((k+l)%2==0) ans&=check(tx+k*m, ty+l*m);
      if (ans){
         cout << "solution " << tx << ' ' << ty << endl;
         return 0;
      }
   }
   assert(false);
   return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 2 ms 344 KB Output is correct