답안 #955267

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

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