Submission #759485

# Submission time Handle Problem Language Result Execution time Memory
759485 2023-06-16T10:46:35 Z gun_gan Aliens (IOI07_aliens) C++17
10 / 100
2 ms 464 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) {
      ll l = 0, r = 1e9, res = 0;
      while(l <= r) {
            ll 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;
            xMin--;
            yMin--;
            xMax++;
            yMax++;
      }

      // 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;     

      assert(xMax - xMin == yMax - yMin && (xMax - xMin + 1) & 1);

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

}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Runtime error 2 ms 464 KB Execution killed with signal 6
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 Runtime error 1 ms 464 KB Execution killed with signal 6
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 Runtime error 2 ms 444 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Runtime error 1 ms 464 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -