제출 #1188184

#제출 시각아이디문제언어결과실행 시간메모리
1188184dzuizzWorm Worries (BOI18_worm)C++20
0 / 100
3079 ms4312 KiB
#include <bits/stdc++.h> int qry(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 ans(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); // TODO do something smart int g[N+2]; memset(g,-1,sizeof g); g[0]=g[N+1]=0; int l=1,r=N; while(l+1<r){ int s=(r-l+1)/3; int lm=l+s,rm=r-s; if(lm==rm) --lm; if(g[lm]==-1) g[lm]=qry(lm,1,1); if(g[rm]==-1) g[rm]=qry(rm,1,1); if(g[lm]>g[rm]) r=rm; else l=lm; } if(g[l]==-1) g[l]=qry(l,1,1); if(g[r]==-1) g[r]=qry(r,1,1); int res=(g[l]>g[r]?l:r); ans(res,1,1); return 0; }

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

worm.cpp: In function 'int qry(int, int, int)':
worm.cpp:7:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |         (void)scanf("%d", &ans);
      |               ~~~~~^~~~~~~~~~~~
worm.cpp: In function 'int main()':
worm.cpp:21:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         (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...