제출 #415140

#제출 시각아이디문제언어결과실행 시간메모리
415140Bill_00커다란 상품 (IOI17_prize)C++14
0 / 100
3 ms1864 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; int l[200005],r[200005],x[200005],answer=-1; void solve(int L,int R){ if(L+1==R){ return; } int m=(L+R)>>1; vector<int>res=ask(m); l[m]=res[0]; r[m]=res[1]; if(l[m]+r[m]==0){ answer=m; return; } if(l[m]!=l[L] || r[m]!=r[L]){ solve(L,m); } if(answer!=-1) return; if(l[m]!=l[R] || r[m]!=r[R]){ solve(m,R); } } int find_best(int n){ // for(int i = 0; i < n; i++){ // std::vector<int> res = ask(i); // if(res[0] + res[1] == 0) // return i; // } for(int i=0;i<n;i++){ l[i]=r[i]=-1; } int m=(n-1)/2; vector<int>res=ask(0); l[0]=res[0]; r[0]=res[1]; if(l[0]+r[0]==0) return 0; res=ask(n-1); l[n-1]=res[0]; r[n-1]=res[1]; if(l[n-1]+r[n-1]==0) return 0; solve(0,n-1); return answer; }

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

prize.cpp: In function 'int find_best(int)':
prize.cpp:34:6: warning: unused variable 'm' [-Wunused-variable]
   34 |  int m=(n-1)/2;
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...