This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "popa.h"
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 1100;
/*int query(int a, int b, int c, int d) {
cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
int answer;
cin>>answer;
return answer;
}*/
int n;
int parent[maxn];
int li[maxn], ri[maxn];
int solvef(int l, int r) {
if(l > r) return -1;
if(l == r) return l;
int index = r;
for(int cekor = n/2; cekor>0;cekor/=2) {
while(index-cekor>=l && query(l, index-cekor, index-cekor, r)) index-=cekor;
}
//cout<<"["<<l<<", "<<r<<"] -> "<<index<<"\n";
li[index] = solvef(l, index-1);
ri[index] = solvef(index+1, r);
return index;
}
// solve function
int solve(int N, int *l , int *r) {
for(int i=0;i<n;i++) {
li[i] = ri[i] = -1;
parent[i] = i;
}
n = N;
int x = solvef(0, n-1);
for(int i=0;i<n;i++) {
l[i] = li[i];
r[i] = ri[i];
//cout<<i<<": "<<l[i]<<" "<<r[i]<<"\n";
}
return x;
}
/*int main() {
int a[6], b[6];
cout<<solve(6, a, b);
return 0;
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |