Submission #759466

# Submission time Handle Problem Language Result Execution time Memory
759466 2023-06-16T10:32:40 Z gun_gan Aliens (IOI07_aliens) C++17
20 / 100
1 ms 208 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll N, X, Y;
ll xMin, xMax, yMin, yMax;

bool can(ll x, ll y) {
      if(x <= 0 || x > N || y <= 0 || y > N) return 0;
      cout << "examine " << x << " " << y << endl;

      string s;
      cin >> s;

      return s == "true"; 
}

void work(int k) {
      int l = 0, r = 1e9, res = 0;
      while(l <= r) {
            int m = (l + r) >> 1;
            if(can(X + 2 * m * dx[k], Y + 2 * m * dy[k])) {
                  l = m + 1, res = m;
            } else {
                  r = m - 1;
            }
      }

      xMin = min(xMin, X + 2 * res * dx[k]);
      xMax = max(xMax, X + 2 * res * dx[k]);
      yMin = min(yMin, Y + 2 * res * dy[k]);
      yMax = max(yMax, Y + 2 * res * dy[k]);     
}

int main() {
      ios_base::sync_with_stdio(0); cin.tie(0);

      cin >> N >> X >> Y;
      xMin = xMax = X;
      yMin = yMax = Y;

      for(int k = 0; k < 4; k++) work(k);

      // cout << xMin << " " << yMin << endl;
      // cout << xMax << " " << yMax << endl;

      int decx = 0, decy = 0, incx = 0, incy = 0;

      if(can(xMin - 1, yMin - 1)) {
            decx = 1;
            decy = 1;
      }

      if(can(xMin - 1, yMax + 1)) {
            decx = 1;
            incy = 1;
      }

      if(can(xMax + 1, yMin - 1)) {
            incx = 1;
            decy = 1;
      }

      if(can(xMax + 1, yMax + 1)) {
            incx = 1;
            incy = 1;
      }      

      xMin -= decx;
      yMin -= decy;
      xMax += incx;
      yMax += incy;     

      cout << "solution " << (xMin + xMax) / 2 << " " << (yMin + yMax) / 2 << endl;

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
# 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 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Incorrect 1 ms 208 KB Incorrect
3 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 Correct 1 ms 208 KB Output is correct
2 Incorrect 1 ms 208 KB Incorrect
3 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 1 ms 208 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 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Incorrect 1 ms 208 KB Incorrect
4 Halted 0 ms 0 KB -