# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
521618 |
2022-02-02T14:59:11 Z |
qwerasdfzxcl |
Park (JOI17_park) |
C++14 |
|
399 ms |
652 KB |
#include "park.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static int Place[1400];
int a[2020];
int ask(int x, int y){return Ask(min(x, y), max(x, y), Place);}
void answer(int x, int y){Answer(min(x, y), max(x, y));}
void _sort(int n){
vector<int> ans = {0};
for (int i=1;i<n;i++){
fill(Place, Place+1400, 1);
int l = 1, r = (int)ans.size()-1, idx = 0;
while(l<=r){
int m = (l+r)>>1;
for (int j=m;j<(int)ans.size();j++) Place[ans[j]] = 0;
if (ask(0, i)) r = m-1;
else l = m+1, idx = m;
for (int j=m;j<(int)ans.size();j++) Place[ans[j]] = 1;
}
ans.insert(ans.begin()+idx+1, i);
}
for (int i=0;i<n;i++) a[i] = ans[i];
}
vector<int> D[2020];
int mxdep = 0;
int getdep(int x){
fill(Place, Place+1400, 0);
Place[x] = 1;
int l = 0, r = mxdep, ret = mxdep;
while(l<=r){
int m = (l+r)>>1;
for (int i=0;i<=m;i++) {
for (auto &x:D[i]) Place[x] = 1;
}
if (ask(0, x)) ret = m, r = m-1;
else l = m+1;
for (int i=0;i<=m;i++) {
for (auto &x:D[i]) Place[x] = 0;
}
}
if (ret==mxdep) mxdep++;
D[ret+1].push_back(x);
return ret+1;
}
void Find(int x, int dep){
fill(Place, Place+1400, 0);
Place[x] = 1;
--dep;
for (int i=0;i<=dep-1;i++){
for (auto &x:D[i]) Place[x] = 1;
}
int pos = 0;
for (int z=1;z<(int)D[dep].size();z<<=1){
for (int i=0;i<(int)D[dep].size();i++) if (i&z) Place[D[dep][i]] = 1;
if (ask(0, x)) pos |= z;
for (int i=0;i<(int)D[dep].size();i++) if (i&z) Place[D[dep][i]] = 0;
}
answer(D[dep][pos], x);
}
void Detect(int T, int N) {
for (int i=1;i<N;i++) a[i] = i;
_sort(N);
printf("A = ");
for (int i=0;i<N;i++) printf("%d ", a[i]);
printf("\n");
D[0].push_back(0);
for (int i=1;i<N;i++){
int dep = getdep(a[i]);
//printf("dep = %d, mxdep = %d\n", dep, mxdep);
Find(a[i], dep);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
332 KB |
Program terminated incorrectly, or you printed something to stdout |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
399 ms |
652 KB |
Program terminated incorrectly, or you printed something to stdout |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
215 ms |
436 KB |
Program terminated incorrectly, or you printed something to stdout |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
114 ms |
332 KB |
Program terminated incorrectly, or you printed something to stdout |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
191 ms |
456 KB |
Program terminated incorrectly, or you printed something to stdout |
2 |
Halted |
0 ms |
0 KB |
- |