Problem - C - Codeforces
题意
思路
code
#include<iostream>
#include<cstdio>
#include<stack>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<vector>
#define int long long
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define long long
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int INF = 1e18 + 10;
const int N = 1e5 + 10;
const int M = 1e7 + 10;
const int mod = 1e9 + 7;
int n, m, k, x, now, ans;
int qcal(int a, int b) { int res = 1; while (b) { if (b & 1) res = res * a % mod; b >>= 1; a = a * a % mod; } return res; }
int a[N], b[N];
bool is_prime(int n) { if (n < 2) return false; for (int i = 2; i <= n / i; i++) { if (n % i == 0) { return false; } }return true; }
int ask(int a, int b)
{
cout << '?' << ' ' << a << ' ' << b << endl;
int x; cin >> x;
return x;
}
void gzy()
{
cin >> n >> m;
int k = ask(1, 1);
int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
if (k + 1 <= n) x1 = 1 + k, y1 = 1;
else x1 = n, y1 = 2 + k - n;
if (k + 1 <= m) x2 = 1, y2 = 1 + k;
else x2 = 2 + k - m, y2 = m;
int k1 = ask(x1, y1), k2 = ask(x2, y2);
//cout << x1 << ' ' << y2 << endl;
int x3 = x1 - k1 / 2, y3 = y1 + k1 / 2;
//cout << x3 << ' ' << y3 << endl;
int x4 = x2 + k2 / 2, y4 = y2 - k2 / 2;
if (ask(x3, y3) == 0) cout << '!' << ' ' << x3 << ' ' << y3 << endl;
else cout << '!' << ' ' << x4 << ' ' << y4 << endl;
}
signed main()
{
int _ = 1; cin >> _;
// int _ = 1;
while (_--) gzy();
return 0;
}
// /**
// * ┏┓ ┏┓+ +
// * ┏┛┻━━━┛┻┓ + +
// * ┃ ┃
// * ┃ ━ ┃ ++ + + +
// * ████━████+
// * ◥██◤ ◥██◤ +
// * ┃ ┻ ┃
// * ┃ ┃ + +
// * ┗━┓ ┏━┛
// * ┃ ┃ + + + +Code is far away from
// * ┃ ┃ + bug with the animal protecting
// * ┃ ┗━━━┓ 神兽保佑,代码无bug
// * ┃ ┣┓
// * ┃ ┏┛
// * ┗┓┓┏━┳┓┏┛ + + + +
// * ┃┫┫ ┃┫┫
// * ┗┻┛ ┗┻┛+ + + +
// */