이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "prize.h"
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int sumMax = 0;
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 < 800 ; 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({500, 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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |