이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
int query(int x, int y, int z) {
printf("? %d %d %d\n", x, y, z);
fflush(stdout);
int ans = -1;
(void)scanf("%d", &ans);
if (ans == -1) exit(0);
return ans;
}
__attribute__((noreturn))
void guess(int x, int y, int z) {
printf("! %d %d %d\n", x, y, z);
exit(0);
}
typedef long long ll;
int N, M, K;
map<ll, int> mp;
int ask(int x, int y, int z){
if (x < 1 || x > N) return 0;
if (y < 1 || y > M) return 0;
if (z < 1 || z > K) return 0;
ll val = x * 1'000'010'000'100LL + y * 1'000'002 + z;
if (mp.find(val) != mp.end()) return mp[val];
return mp[val] = query(x, y, z);
}
int main() {
int Q;
(void)scanf("%d %d %d %d", &N, &M, &K, &Q);
int l = 1, r = N;
int ans = -1;
while (l <= r){
int mid = (l + r) >> 1;
if (ask(mid, 1, 1) >= ask(mid + 1, 1, 1)){
ans = mid;
r = mid - 1;
} else {
ans = mid + 1;
l = mid + 1;
}
}
guess(1, 1, ans);
}
컴파일 시 표준 에러 (stderr) 메시지
worm.cpp: In function 'int query(int, int, int)':
worm.cpp:11:13: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
11 | (void)scanf("%d", &ans);
| ~~~~~^~~~~~~~~~~~
worm.cpp: In function 'int main()':
worm.cpp:39:13: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
39 | (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... |