이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <stdlib.h>
#include <map>
#include <iostream>
using namespace std;
#define deb(x) cerr << #x << " = " << x << '\n'
map<int, int> mp;
int query(int x, int y, int z) {
if(mp.count(x))
return mp[x];
printf("? %d %d %d\n", x, y, z);
fflush(stdout);
int ans = -1;
(void)scanf("%d", &ans);
if (ans == -1) exit(0);
return mp[x] = ans;
}
__attribute__((noreturn))
void guess(int x, int y, int z) {
printf("! %d %d %d\n", x, y, z);
exit(0);
}
int main() {
int N, M, K, Q;
(void)scanf("%d %d %d %d", &N, &M, &K, &Q);
int l = 1, r = N;
for(int i = 1; i <= 17; i ++)
{
int ml = (l + l + r) / 3;
int mr = (l + r + r) / 3;
int fl = query(ml, 1, 1), fr = query(mr, 1, 1);
if(fl < fr)
{
l = ml;
}
else
r = mr;
}
int loo = query(l, 1, 1), roo = query(r, 1, 1), moo = query((l+r)/2, 1, 1);
int ans = 0;
if(moo > loo && moo > roo && r - l > 1)
ans = (l + r ) / 2;
else
if(loo > roo)
ans = l;
else
ans = r;
// deb(l);
// deb(loo);
// deb(r);
// deb(roo);
guess(ans, 1, 1);
}
컴파일 시 표준 에러 (stderr) 메시지
worm.cpp: In function 'int query(int, int, int)':
worm.cpp:14:2: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
(void)scanf("%d", &ans);
^~~~~~~~~~~~~~~~~~~~~~~
worm.cpp: In function 'int main()':
worm.cpp:28:2: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
(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... |