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"
using namespace std;
#define LL long long
#define MP make_pair
#define PB push_back
#include"park.h"
int n;
bool great(int root, int a, int b){ //a < b
int P[1400];
for(int i=0; i<n; i++) P[i] = 1;
P[a] = 0;
if(Ask(root, b, P) == 0) return true;
else return false;
}
void Detect(int T, int N){
if(T != 2) return;
n = N;
int p[1400];
p[0] = 0;
p[N-1] = N-1;
queue<pair<int,vector<int>>> que;
vector<int> v;
for(int i=1; i<N-1; i++) v.PB(i);
que.push(MP(1, v));
while(!que.empty()){
int left = que.front().first;
v = que.front().second;
que.pop();
vector<int> vSmall,vLarge;
for(int i=1; i<v.size(); i++){
if(great(p[left-1], v[0], v[i])) vLarge.PB(v[i]);
else vSmall.PB(v[i]);
}
p[left+vSmall.size()] = v[0];
if(vSmall.size() > 0) que.push(MP(left, vSmall));
if(vLarge.size() > 0) que.push(MP(left+vSmall.size()+1, vLarge));
}
for(int i=0; i<N; i++) cout << p[i] << endl;
for(int i=0; i<N-1; i++) Answer(min(p[i], p[i+1]), max(p[i], p[i+1]));
}
Compilation message (stderr)
park.cpp: In function 'void Detect(int, int)':
park.cpp:33:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=1; i<v.size(); i++){
~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |