제출 #430211

#제출 시각아이디문제언어결과실행 시간메모리
430211AmineWeslati커다란 상품 (IOI17_prize)C++14
20 / 100
96 ms3504 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int>vi; #define pb push_back #define sz(x) (int)x.size() #define all(x) begin(x),end(x) #define FOR(i,a,b) for(int i=a; i<b; i++) //----------------------------------------------------- const int MX=2e5+10; int memo[MX][2]; int cnt=0; vi query(int i){ if(memo[i][0]==-1){ cnt++; if(cnt>10000) assert(0); vi vec=ask(i); memo[i][0]=vec[0]; memo[i][1]=vec[1]; } return vi{memo[i][0],memo[i][1]}; } int find_best(int N){ memset(memo,-1,sizeof(memo)); int lft=0; while(lft<N){ vi v=query(lft); if(v[0]+v[1]==0) return lft; int l=lft,r=N-1,rgt; while(l<=r){ int m=(l+r)/2; vi vv=query(m); if(v[0]+v[1]!=vv[0]+vv[1]) r=m-1; else{ if(v[0]==vv[0]){ rgt=m; l=m+1; } else r=m-1; } } lft=rgt+1; } assert(0); }

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

prize.cpp: In function 'int find_best(int)':
prize.cpp:55:6: warning: 'rgt' may be used uninitialized in this function [-Wmaybe-uninitialized]
   55 |   lft=rgt+1;
      |   ~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...