답안 #1002287

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1002287 2024-06-19T11:53:46 Z gyg Cup of Jamshid (IOI17_cup) C++17
0 / 100
1 ms 344 KB
#include "cup.h"
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
const int INF = 1e9, MAX = 5e8;

vector<int> find_cup() {
    int k = ask_shahrasb(-INF, -INF);

    int x = 0;
    for (int i = 0; i <= 28; i++) {
        int resp = ask_shahrasb(-INF + (1 << i), -INF);
        if (resp != (k ^ (1 << i))) continue;
        x ^= (1 << i);
    }
    for (pii bits : {make_pair(0, 0), make_pair(0, 1)}) {
        int new_x = x | (bits.first << 30) | (bits.second << 29);
        int new_y = new_x ^ k;
        
        auto is_valid = [](int x) { return -MAX <= x && x <= MAX; };
        if (!is_valid(-INF + new_x) || !is_valid(-INF + new_y)) continue;

        // cout << new_x << " " << new_y << endl;
        int pos = rand();
        if (ask_shahrasb(-INF + new_x, pos) != abs(-INF + new_y - pos)) continue;
        // cout << new_x << " " << new_y << endl;

        return {-INF + new_x, -INF + new_y};
    }
    x |= (1 << 30);
    int y = x ^ k;
    return {-INF + x, -INF + y};
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB WA in grader: -1
2 Halted 0 ms 0 KB -