제출 #1358743

#제출 시각아이디문제언어결과실행 시간메모리
1358743maya_sWorm Worries (BOI18_worm)C++20
10 / 100
0 ms412 KiB
#include <stdio.h>
#include <stdlib.h>
#include<bits/stdc++.h>
using namespace std;
typedef int ll;

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);
}

void solve(ll n, ll m, ll k){
	ll lo = 1, mid = (n + 1) / 2, hi = n, a = query(lo, 1, 1), b = query(mid, 1, 1), c = query(hi, 1, 1);
	while(lo < hi){
		ll range = (mid - lo) / 2;
		if(max({a, b, c}) == b){
			lo = max(mid - range, 1), hi = min(mid + range, n), a = query(lo, 1, 1), c = query(hi, 1, 1);
		}
		else if(max({a, b, c}) == a){
			mid = lo; b = a;
			lo = max(mid - range, 1), hi = min(mid + range, n), a = query(lo, 1, 1), c = query(hi, 1, 1);
		}
		else{
			mid = hi; b = c;
			lo = max(mid - range, 1), hi = min(mid + range, n), a = query(lo, 1, 1), c = query(hi, 1, 1);
		}
	}
	guess(lo, 1, 1);
}


int main() {
	int N, M, K, Q;
	(void)scanf("%d %d %d %d", &N, &M, &K, &Q);
	solve(N, M, K);
}

컴파일 시 표준 에러 (stderr) 메시지

worm.cpp: In function 'int query(int, int, int)':
worm.cpp:11:20: 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:44:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |         (void)scanf("%d %d %d %d", &N, &M, &K, &Q);
      |               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...