제출 #775768

#제출 시각아이디문제언어결과실행 시간메모리
775768APROHACK커다란 상품 (IOI17_prize)C++14
20 / 100
41 ms348 KiB
#include "prize.h" #include <bits/stdc++.h> #define ll long long #define pb push_back using namespace std; int sumMax = 0, start = 450; struct range{ int ff, ss, izq, der; }; bool confirm(vector<int>&t){ return t[0] + t[1] == 0; } int suma(vector<int>&t){return t[0] + t[1];} int find_best(int n) { vector<int>t; vector<int>answers; for(int i = 0 ; i < start ; i ++){ t = ask(i); answers.pb(suma(t)); sumMax = max(sumMax, suma(t)); if(confirm(t))return i; } int tempp = 0; for(auto i : answers){ if(i < sumMax){ tempp++; } } queue<range>cola; cola.push({start, n-1, tempp, 0}); while(!cola.empty()){ range cur = cola.front(); cola.pop(); if(cur.ff > cur.ss)continue; if(cur.ff == cur.ss){ t = ask(cur.ff); if(confirm(t))return cur.ff; } int midd = (cur.ff + cur.ss)/2, toL, k, cuenta = 0; t = ask(midd); k = midd; toL = midd-1; bool thereIsR = true; while(suma(t) != sumMax){ if(confirm(t))return k; k++; cuenta ++ ; if(k > cur.ss){ thereIsR = false; break; } t = ask(k); } if(confirm(t))return k; if(t[1] - cur.der > 0 and thereIsR and k+1 <= cur.ss){ cola.push({k+1, cur.ss, t[0], cur.der}); } if(thereIsR and t[0]-cuenta- cur.izq > 0 and toL >= cur.ff)cola.push({cur.ff, toL, cur.izq, t[1] + cuenta}); else if(t[0]-cuenta- cur.izq > 0 and toL >= cur.ff){ cola.push({cur.ff, toL, cur.izq, cur.der + cuenta}); } //if(t[0] > 0 and toL >= cur.ff)cola.push({cur.ff, toL}); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...