제출 #1358162

#제출 시각아이디문제언어결과실행 시간메모리
1358162toast12Cup of Jamshid (IOI17_cup)C++20
100 / 100
1 ms344 KiB
#include "cup.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> find_cup() {
    vector<long long> ans(2);
    int mx = 5e8+1;
    ans[0] = mx, ans[1] = mx;
    int res = ask_shahrasb(ans[0], ans[1]);
    for (int i = 29; i >= 0; i--) {
        if (res & (1<<i)) {
            int res2 = ask_shahrasb(mx-(1<<i), mx);
            if ((res2^res) == (1<<i)) ans[1] += (1<<i);
            else ans[0] += (1<<i);
        }
        else {
            int res2 = ask_shahrasb(mx-(1<<i), mx);
            if ((res2^res) != (1<<i)) {
                ans[0] += (1<<i);
                ans[1] += (1<<i);
            }
        }
    }
    if (ans[0] > mx) ans[0] = ans[0]-(1<<30)+1;
    if (ans[1] > mx) ans[1] = ans[1]-(1<<30)+1;
    return {(int)ans[0], (int)ans[1]};
}
#Verdict Execution timeMemoryGrader output
Fetching results...