#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll,ll>
#define all(x) (x).begin(),(x).end()
map<array<int,3>,int> mem;
int n, m, k, q;
int query(int x=1, int y=1, int z=1) {
if (mem.count({x,y,z})) {
return mem[{x,y,z}];
}
if (x<1 || n<x || y<1 || m<y || z<1 || k<z) {
return 0;
}
printf("? %d %d %d\n", x, y, z);
fflush(stdout);
int ans = -1;
(void)scanf("%d", &ans);
if (ans == -1) exit(0);
mem[{x,y,z}]=ans;
return ans;
}
__attribute__((noreturn))
void guess(int x=1, int y=1, int z=1) {
printf("! %d %d %d\n", x, y, z);
exit(0);
}
int main() {
(void)scanf("%d %d %d %d", &n, &m, &k, &q);
int l=1,r=n;
while (l<r) {
int m=l+(r-l)/2;
if (query(m)>=query(m+1)) {
r=m;
}
else {
l=m+1;
}
}
guess(l);
}
컴파일 시 표준 에러 (stderr) 메시지
worm.cpp: In function 'int query(int, int, int)':
worm.cpp:27:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
27 | (void)scanf("%d", &ans);
| ~~~~~^~~~~~~~~~~~
worm.cpp: In function 'int main()':
worm.cpp:41:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
41 | (void)scanf("%d %d %d %d", &n, &m, &k, &q);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |