답안 #955314

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
955314 2024-03-30T05:56:33 Z Lithanium Aliens (IOI07_aliens) C++17
80 / 100
2 ms 352 KB
#include <bits/stdc++.h>
using namespace std;
 
#define int long long

int n;
 
bool use_device(int a, int b) {
  if (min(a, b) < 1 or min(a, b) > n) return 0;
	cout << "examine " << a << " " << b << endl;
  	string res;
  	cin >> res;
  	return (res == "true");
}
 
pair<int, int> help_aliens(int sx, int sy) {
    int l, r, b;
    int low = sx, high = n;
    for (int i = 0; sx + (1 << i) <= n; i ++) {
        int nx = sx + (1 << i);
        if (!use_device(nx, sy)) {
            high = nx;
            if (i != 0) {
                low = sx + (1 << (i-1));
            }
            break;
        }
    }
    while (high > low) {
        int mid = (high + low + 1)/2;
        if (use_device(mid, sy)) low = mid;
        else high = mid - 1;
    }
    r = low;
    low = 1, high = sx;
    for (int i = 0; sx - (1 << i) > 0; i ++) {
        int nx = sx - (1 << i);
        if (!use_device(nx, sy)) {
            low = nx;
            if (i != 0) {
                high = sx - (1 << (i-1));
            }
            break;
        }
    }
    while (high > low) {
        int mid = (high + low)/2;
        if (use_device(mid, sy)) high = mid;
        else low = mid + 1;
    }
    l = low;
    low = 1, high = sy;
    for (int i = 0; sy - (1 << i) > 0; i ++) {
        int ny = sy - (i << i);
        if (!use_device(sx, ny)) {
            low = ny;
            if (i != 0) {
                high = sy - (1 << (i-1));
            }
            break;
        }
    }
    while (high > low) {
        int mid = (high + low)/2;
        if (use_device(sx, mid)) high = mid;
        else low = mid + 1;
    }
    b = low;
    int cx = (l + r)/2, cy = b + (r - l)/2;
    int m = r - l + 1;
    int x1 = 0, x2 = 0;
    for (int i = 1; i <= 4; i ++) {
        int qx = cx - 2*m*i;
        if (qx < 1) break;
        if (use_device(qx, cy)) x1 ++;
        else break;
    }
    for (int i = 1; i <= 4; i ++) {
        int qx = cx + 2*m*i;
        if (qx > n) break;
        if (use_device(qx, cy)) x2 ++;
        else break;
    }
    int y1 = 0, y2 = 0;
    for (int i = 1; i <= 4; i ++) {
        int qy = cy - 2*m*i;
        if (qy < 1) break;
        if (use_device(cx, qy)) y1 ++;
        else break;
    }
    for (int i = 1; i <= 4; i ++) {
        int qy = cy + 2*m*i;
        if (qy > n) break;
        if (use_device(cx, qy)) y2 ++;
        else break;
    }
    cx += m*(x2 - x1);
    cy += m*(y2 - y1);
    return {cx, cy};
}
 
signed main() {
	int b, c;
  	cin >> n >> b >> c;
  	pair<int, int> t = help_aliens(b, c);
  	cout << "solution " << t.first << " " << t.second;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB Incorrect
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 2 ms 352 KB Output is correct