Hello codeforces, yesterday I read this problem [problem:1934C] and I thought and today I am trying to solve it, I get the solution but it has a bug please can you help me this is my code:↵
#include "bits/stdc++.h"↵
using namespace std;↵
int32_t main()↵
{↵
↵
//ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);↵
int t;↵
cin >> t;↵
while (t--)↵
{↵
int n , m , d1 , d2 , d3 , d4;↵
cin >> n >> m; n-- , m--;↵
cout << "? " << 1 << " " << 1 << "\n";↵
cin >> d1;↵
cout << "? " << 1 << " " << m+1 << "\n";↵
cin >> d2;↵
cout << "? " << n+1 << " " << m+1 << "\n";↵
cin >> d3;↵
int y = (m+d1-d2)/2 , x = d1-y;↵
if (x < 0) x += 0-x; if (y > m) y -= y-m;↵
if (y < 0) y += 0-x; if (x > n) x -= x-n;↵
cout << "? " << x+1 << " " << y+1 << "\n";↵
cin >> d4;↵
if (d4 == 0){↵
cout << "! " << x+1 << " " << y+1 << "\n";↵
continue;↵
}↵
x = (n+d1-d3)/2 , y = x+m-d2;↵
cout << "! " << x+1 << " " << y+1 << "\n";↵
cout << "\n";↵
}↵
return 0;↵
}↵
Thanks very much!
#include "bits/stdc++.h"↵
using namespace std;↵
int32_t main()↵
{↵
↵
//ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);↵
int t;↵
cin >> t;↵
while (t--)↵
{↵
int n , m , d1 , d2 , d3 , d4;↵
cin >> n >> m; n-- , m--;↵
cout << "? " << 1 << " " << 1 << "\n";↵
cin >> d1;↵
cout << "? " << 1 << " " << m+1 << "\n";↵
cin >> d2;↵
cout << "? " << n+1 << " " << m+1 << "\n";↵
cin >> d3;↵
int y = (m+d1-d2)/2 , x = d1-y;↵
if (x < 0) x += 0-x; if (y > m) y -= y-m;↵
if (y < 0) y += 0-x; if (x > n) x -= x-n;↵
cout << "? " << x+1 << " " << y+1 << "\n";↵
cin >> d4;↵
if (d4 == 0){↵
cout << "! " << x+1 << " " << y+1 << "\n";↵
continue;↵
}↵
x = (n+d1-d3)/2 , y = x+m-d2;↵
cout << "! " << x+1 << " " << y+1 << "\n";↵
cout << "\n";↵
}↵
return 0;↵
}↵
Thanks very much!