제출 #600422

#제출 시각아이디문제언어결과실행 시간메모리
600422StrawHatWess커다란 상품 (IOI17_prize)C++17
20 / 100
3054 ms1884 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i,a,b) for(int i=a; i<b; i++) typedef vector<int>vi; #define pb push_back #define sz(x) (int)x.size() #define all(x) begin(x), end(x) typedef pair<ll,ll>pi; typedef vector<pi>vpi; #define fi first #define se second template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; } template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } const ll INF=1e18; //------------------------------------- const int MX=2e5+10; vi L(MX,-1), R(MX,-1); int cnt=0; vi query(int i){ if(L[i]==-1){ cnt++; if(cnt>10000) assert(0); vi vec=ask(i); L[i]=vec[0]; R[i]=vec[1]; } return vi{L[i],R[i]}; } const int B=450; int find_best(int N) { int X=0,idx; FOR(i,0,min(N,B)){ vi vec=query(i); if(vec[0]==0 && vec[1]==0) return i; if(ckmax(X,vec[0]+vec[1])) idx=i; } vi tmp=query(idx); int done=0; while(idx<N){ int l=idx, r=N-1, nxt=N; while(l<=r){ int m=(l+r)/2; vi vec=query(m); if(vec[0]==0 && vec[1]==0) return m; if(vec[0]+vec[1]<X) nxt=m, r=m-1; else{ if(vec[0]==tmp[0]-done) l=m+1; else r=m-1; } } /*if(nxt!=N){ while(nxt<N){ vi vec=query(nxt); if(vec[0]==0 && vec[1]==0) return nxt; if(vec[0]+vec[1]==X) break; nxt++; } }*/ done++; idx=nxt; } //assert(0); } /* 8 3 2 3 1 3 3 2 3 */ /* 10 3 3 2 3 3 3 1 2 3 3 */

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

prize.cpp: In function 'int find_best(int)':
prize.cpp:51:18: warning: control reaches end of non-void function [-Wreturn-type]
   51 |  vi tmp=query(idx);
      |                  ^
prize.cpp:59:12: warning: 'idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
   59 |    int m=(l+r)/2;
      |          ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...