#include <bits/stdc++.h>
using namespace std;
int max_Q;
int n, m, k;
int cnt_q = 0;
#ifdef LOCAL
vector<vector<vector<int>>> mat;
#endif
int ask(int x, int y, int z) {
cout << "? " << x << ' ' << y << ' ' << z << endl;
int ans = -1;
#ifdef LOCAL
cnt_q ++;
if(x > n || y > m || z > k || cnt_q > max_Q){
ans = -1;
}else{
ans = mat[x - 1][y - 1][z - 1];
}
#else
cin >> ans;
#endif
if (ans == -1) exit(0);
return ans;
}
__attribute__((noreturn))
void guess(int x, int y, int z) {
cout << "! " << x << ' ' << y << ' ' << z;
cout << endl;
exit(0);
}
mt19937 mt();
void sub1(int &n){
int l = 1, r = n;
while(l < r){
int m = (l + r) >> 1;
int h = ask(m + 1, 1, 1);
int hh = ask(m, 1, 1);
if(l == r - 1){
if(h > hh){
guess(m + 1, 1, 1);
}else{
guess(m, 1, 1);
}
}
if(h >= hh){
l = m + 1;
}else{
r = m;
}
}
guess(r, 1, 1);
}
void solve(){
cin >> n >> m >> k;
cin >> max_Q;
#ifdef LOCAL
mat.assign(n, vector(m, vector(k, 0)));
for(int i = 0; i < n; i ++){
for(int j = 0; j < m; j ++){
for(int ii = 0; ii < k; ii ++){
cin >> mat[i][j][ii];
}
}
}
#endif
sub1(n);
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int testcases = 1;
while(testcases --){
solve();
if(testcases) cout << '\n';
#ifdef LOCAL
else cout << '\n';
cout << "__________________________" << endl;
#endif
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
too many queries. input: ? 499997 1 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Incorrect |
1 ms |
208 KB |
not a local maximum |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Incorrect |
1 ms |
244 KB |
not a local maximum |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Incorrect |
1 ms |
208 KB |
not a local maximum |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Incorrect |
1 ms |
208 KB |
not a local maximum |
3 |
Halted |
0 ms |
0 KB |
- |