제출 #931432

#제출 시각아이디문제언어결과실행 시간메모리
931432Lobo커다란 상품 (IOI17_prize)C++17
97.71 / 100
30 ms2180 KiB
#include "prize.h" #include<bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define fr first #define sc second map<int,pair<int,pair<int,int>>> qr; int cnt = 0; int cntnonlol; int n; pair<int,pair<int,int>> query(int i) { if(i == n) return mp(cntnonlol,mp(cntnonlol,0)); if(qr.count(i)) return qr[i]; ++cnt; vector<int> perg = ask(i); return qr[i] = mp(perg[0]+perg[1],mp(perg[0],perg[1])); } int find_best(int N) { n = N; stack<pair<int,int>> q; q.push(mp(0,n-1)); while(q.size()) { int l = q.top().fr; int r = q.top().sc; q.pop(); if(l > r) continue; if(query(l).fr == 0) return l; if(query(r).fr == 0) return r; if(r-l+1 <= 2) continue; if(query(l) == query(r)) continue; int mid = (l+r+rand()%2)/2; q.push(mp(l,mid)); q.push(mp(mid,r)); } assert(false); return -1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...