# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
521619 |
2022-02-02T14:59:33 Z |
qwerasdfzxcl |
Park (JOI17_park) |
C++14 |
|
424 ms |
668 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 |
1 ms |
332 KB |
Wrong Answer[6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
423 ms |
584 KB |
Output is correct |
2 |
Correct |
221 ms |
492 KB |
Output is correct |
3 |
Correct |
235 ms |
476 KB |
Output is correct |
4 |
Correct |
424 ms |
492 KB |
Output is correct |
5 |
Correct |
404 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
216 ms |
548 KB |
Output is correct |
2 |
Correct |
222 ms |
452 KB |
Output is correct |
3 |
Correct |
240 ms |
352 KB |
Output is correct |
4 |
Correct |
212 ms |
568 KB |
Output is correct |
5 |
Correct |
247 ms |
448 KB |
Output is correct |
6 |
Correct |
221 ms |
444 KB |
Output is correct |
7 |
Correct |
225 ms |
452 KB |
Output is correct |
8 |
Correct |
230 ms |
456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
424 KB |
Output is correct |
2 |
Correct |
254 ms |
452 KB |
Output is correct |
3 |
Correct |
246 ms |
472 KB |
Output is correct |
4 |
Correct |
269 ms |
580 KB |
Output is correct |
5 |
Correct |
287 ms |
468 KB |
Output is correct |
6 |
Correct |
338 ms |
500 KB |
Output is correct |
7 |
Correct |
296 ms |
464 KB |
Output is correct |
8 |
Correct |
263 ms |
460 KB |
Output is correct |
9 |
Correct |
262 ms |
452 KB |
Output is correct |
10 |
Correct |
303 ms |
588 KB |
Output is correct |
11 |
Correct |
338 ms |
484 KB |
Output is correct |
12 |
Correct |
281 ms |
460 KB |
Output is correct |
13 |
Correct |
316 ms |
460 KB |
Output is correct |
14 |
Correct |
344 ms |
476 KB |
Output is correct |
15 |
Correct |
306 ms |
576 KB |
Output is correct |
16 |
Correct |
221 ms |
452 KB |
Output is correct |
17 |
Correct |
411 ms |
668 KB |
Output is correct |
18 |
Correct |
345 ms |
460 KB |
Output is correct |
19 |
Correct |
347 ms |
484 KB |
Output is correct |
20 |
Correct |
269 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
182 ms |
448 KB |
Wrong Answer[2] |
2 |
Halted |
0 ms |
0 KB |
- |