// M
#include<bits/stdc++.h>
#include "cup.h"
using namespace std;
vector < int > find_cup()
{
int K = 5e8;
int Xor = ask_shahrasb(-K, -K);
int LG = 30;
vector < int > Rs = {0, 0};
for (int i = 0; i < LG - 1; i ++)
{
int a = ask_shahrasb(-K - (1 << i), -K);
int df = a ^ Xor;
int lb = -1;
for (int j = i; j < LG; j ++)
if (df >> j & 1)
lb = j;
assert(lb != -1);
for (int j = i; j < lb; j ++)
Rs[0] |= 1 << j;
i = lb;
}
{
int a2 = Rs[0] | (1 << (LG - 1)), b2 = a2 ^ Xor;
a2 -= K; b2 -= K;
int f1 = ask_shahrasb(a2 - 1, b2);
//int f2 = ask_shahrasb(a2, b2);
int f3 = ask_shahrasb(a2 + 1, b2);
if (f1 == 1 && f3 == 1)
Rs[0] |= 1 << (LG - 1);
}
Rs[1] = Rs[0] ^ Xor;
Rs[0] -= K;
Rs[1] -= K;
return Rs;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |