This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937 rng(chrono::steady_clock().now().time_since_epoch().count());
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
const int maxn5 = 3e5 + 10;
map <pair<int, int>, ll> av;
vector <pair<int, int>> qu;
int n, m, k, q;
inline ll ask(int x){
int y = 1;
if(av.find({x, y}) != av.end())
return av[{x, y}];
if(x < 1 || x > n || y < 1 || y > m)
return -1;
cout << "? " << x << ' ' << y << ' ' << 1 << endl;
cin >> av[{x, y}];
if(av[{x, y}] == -1)
exit(0);
return av[{x, y}];
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> n >> m >> k >> q;
if(ask(1) >= ask(2))
return cout << "! " << 1 << ' ' << 1 << ' ' << 1 << endl, 0;
if(ask(n - 1) <= ask(n))
return cout << "! " << n << ' ' << 1 << ' ' << 1 << endl, 0;
int l = 1, r = n;
while(r - l > 1){
int mid = (l + r) >> 1;
if(ask(mid) < ask(mid + 1))
l = mid;
else
r = mid;
}
cout << "! " << l + 1 << ' ' << 1 << ' ' << 1 << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |