#include "park.h"
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int) (x).size()
#define all(x) (x).begin(), (x).end()
#define show(x) cerr << #x << " is " << x << endl;
#define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl;
#define tern(cond, a, b) (cond ? a : b)
typedef long long lint;
typedef pair<lint,lint> ii;
vector<int> done;
static int place[1400];
static int indone[1400];
int n;
int query(int S, int E, vector<int> stuff, bool assumedone=true){
if(S > E) swap(S,E);
for(int i = 0;i < n;i++) place[i] = 0;
for(int x : stuff) place[x] = 1;
if(assumedone) for(int x : done) place[x] = 1;
place[S] = 1, place[E] = 1;
//show2(S,E);
//for(int i = 0;i < n;i++) cerr << place[i]; cerr << endl;
return Ask(S, E, place);
}
void findmiddle(int S, int E, vector<int> &v){
vector<int> possible;
for(int i = 0;i < n;i++){
if(i == S or i == E or indone[i]) continue;
possible.push_back(i);
}
random_shuffle(all(possible));
//for(int x : possible) cerr << x << " "; cerr << endl;
if(query(S, E, {})){
v.push_back(E);
return;
}
int low = 0, high = sz(possible)-1;
while(low < high){
int mid = (low+high)/2;
vector<int> toask;
for(int i = 0;i < sz(possible);i++){
if(low <= i and i <= mid) continue;
toask.push_back(possible[i]);
}
if(query(S, E, toask)) low = mid+1;
else high = mid;
//for(int x : toask) cerr << x << " "; cerr << endl;
}
//show3(S, E, possible[low]);
findmiddle(S, possible[low], v);
findmiddle(possible[low],E,v);
}
void answer(int A, int B){
if(A > B) swap(A,B);
show2(A,B);
Answer(A,B);
}
void Detect(int T, int _n){
n = _n;
if(T == 1){
for(int i = 0;i < n;i++){
for(int j = i+1;j < n;j++){
if(query(i,j,{i,j},false)){
answer(i,j);
}
}
}
return;
}
int seed = time(0);
srand(seed);
show(seed);
vector<int> possible;
for(int i = 1;i < n;i++) possible.push_back(i);
done.push_back(0);
indone[0] = 1;
while(true){
vector<int> undone;
for(int i = 0;i < n;i++) if(not indone[i]) undone.push_back(i);
if(sz(undone) == 0) break;
vector<int> erm;
findmiddle(0, undone[rand()%sz(undone)], erm);
//for(int x : erm) cerr << x << " "; cerr << endl;
int low = -1, high = sz(done)-1;
int u = erm[0];
while(low != high-1){
int mid = (low+high)/2;
vector<int> stuff;
for(int i = 0;i <= mid;i++) stuff.push_back(done[i]);
if(query(0, u, stuff, false)) high = mid;
else low = mid;
}
//show2(u, done[high]);
answer(u, done[high]);
for(int i = 1;i < sz(erm);i++) answer(erm[i-1], erm[i]);
///push back into order
for(int x : erm){
done.push_back(x);
indone[x] = 1;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
11 ms |
336 KB |
Output is correct |
3 |
Correct |
11 ms |
332 KB |
Output is correct |
4 |
Correct |
13 ms |
332 KB |
Output is correct |
5 |
Correct |
18 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
261 ms |
664 KB |
Output is correct |
2 |
Correct |
225 ms |
736 KB |
Output is correct |
3 |
Correct |
223 ms |
832 KB |
Output is correct |
4 |
Correct |
277 ms |
640 KB |
Output is correct |
5 |
Correct |
245 ms |
580 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
317 ms |
484 KB |
Output is correct |
2 |
Correct |
331 ms |
604 KB |
Output is correct |
3 |
Correct |
345 ms |
576 KB |
Output is correct |
4 |
Correct |
342 ms |
460 KB |
Output is correct |
5 |
Correct |
353 ms |
580 KB |
Output is correct |
6 |
Correct |
330 ms |
476 KB |
Output is correct |
7 |
Correct |
337 ms |
484 KB |
Output is correct |
8 |
Correct |
320 ms |
584 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
188 ms |
448 KB |
Output is correct |
2 |
Correct |
391 ms |
624 KB |
Output is correct |
3 |
Correct |
376 ms |
516 KB |
Output is correct |
4 |
Correct |
372 ms |
524 KB |
Output is correct |
5 |
Correct |
387 ms |
560 KB |
Output is correct |
6 |
Correct |
292 ms |
588 KB |
Output is correct |
7 |
Correct |
368 ms |
584 KB |
Output is correct |
8 |
Correct |
361 ms |
520 KB |
Output is correct |
9 |
Correct |
368 ms |
516 KB |
Output is correct |
10 |
Correct |
392 ms |
684 KB |
Output is correct |
11 |
Correct |
427 ms |
564 KB |
Output is correct |
12 |
Correct |
356 ms |
540 KB |
Output is correct |
13 |
Correct |
342 ms |
552 KB |
Output is correct |
14 |
Correct |
367 ms |
580 KB |
Output is correct |
15 |
Correct |
337 ms |
536 KB |
Output is correct |
16 |
Correct |
324 ms |
460 KB |
Output is correct |
17 |
Correct |
253 ms |
596 KB |
Output is correct |
18 |
Correct |
366 ms |
684 KB |
Output is correct |
19 |
Correct |
309 ms |
608 KB |
Output is correct |
20 |
Correct |
361 ms |
528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1514 ms |
33396 KB |
Wrong Answer[5] |
2 |
Halted |
0 ms |
0 KB |
- |