제출 #72471

#제출 시각아이디문제언어결과실행 시간메모리
72471Kmcode커다란 상품 (IOI17_prize)C++14
97.67 / 100
55 ms968 KiB
#include<bits/stdc++.h> using namespace std; //#include "prize.h" #include <vector> int find_best(int n); std::vector<int> ask(int i); namespace solver{ map<int,pair<int,int> > mp; int fin; pair<int,int> query(int box){ if(box==-1){ return make_pair(0,-111); } if(mp.count(box))return mp[box]; auto z=ask(box); if(z[0]==0&&z[1]==0){ fin=box; } return mp[box]=make_pair(z[0],z[1]); } int mx; inline void dfs(int l,int r){ int ex=query(r-1).first-query(l-1).first; int r_cn=query(r-1).first+query(r-1).second; int l_cn=query(l-1).first+query(l-1).second; mx=max(mx,r_cn); mx=max(mx,l_cn); while(r>l&&r_cn!=mx&&fin!=-1){ r--; r_cn=query(r-1).first+query(r-1).second; mx=max(mx,r_cn); } while(r>l&&l_cn!=mx&&fin!=-1){ l++; l_cn=query(l-1).first+query(l-1).second; mx=max(mx,l_cn); } if(r<=l)return; if(fin!=-1)return; if(r_cn==l_cn&&query(l-1).first==query(r-1).first)return; if(query(r-1).first==0)return; if(l+1==r)return; if(fin!=-1)return; dfs(l,(l+r)>>1); if(fin!=-1)return; dfs((l+r)>>1,r); } int find_best(int n) { fin=-1; dfs(0,n); return fin; } } int find_best(int n) { return solver::find_best(n); }

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

prize.cpp: In function 'void solver::dfs(int, int)':
prize.cpp:27:7: warning: unused variable 'ex' [-Wunused-variable]
   int ex=query(r-1).first-query(l-1).first;
       ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...