You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
874 B
C++
41 lines
874 B
C++
#define _CRT_SECURE_NO_WARNINGS
|
|
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
|
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
int ask(int c, int d)
|
|
{
|
|
fflush(stdout);
|
|
int ret;
|
|
printf("? %d %d\n", c, d);
|
|
fflush(stdout);
|
|
scanf("%d", &ret);
|
|
fflush(stdout);
|
|
return ret;
|
|
}
|
|
int main()
|
|
{
|
|
fflush(stdout);
|
|
int a = 0, b = 0, big = ask(0, 0);
|
|
for (int i = 29; i >= 0; i--)
|
|
{
|
|
int f = ask(a ^ (1 << i), b), s = ask(a, b ^ (1 << i));
|
|
if (f == s)
|
|
{
|
|
if (big == 1)
|
|
a ^= (1 << i);
|
|
else
|
|
b ^= (1 << i);
|
|
big = f;
|
|
}
|
|
else if (f == -1)
|
|
{
|
|
a ^= (1 << i);
|
|
b ^= (1 << i);
|
|
}
|
|
}
|
|
fflush(stdout);
|
|
printf("! %d %d\n", a, b);
|
|
fflush(stdout);
|
|
return 0;
|
|
}
|