#include <bits/stdc++.h>
#include "park.h"
using namespace std;
int P[1400];
int ask(int a, int b){
if(P[a] == 0 || P[b] == 0) return 0;
if(a == b) return 1;
return Ask(min(a,b), max(a,b), P);
}
void solve1(int n){
for(int i = 0; i < n; i++){
for(int j = i+1; j < n; j++){
P[i] = P[j] = 1;
if(ask(i,j)){
Answer(i, j);
}
P[i] = P[j] = 0;
}
}
}
void solvetree(vector<int> v, int n){
if(v.size() <= 1) return;
while(1){
int a = v[rand() % v.size()];
int b = v[rand() % v.size()];
if(a >= b) continue;
for(int i = 0; i < n; i++){
P[i] = 0;
}
P[a] = P[b] = 1;
if(!ask(a,b)){
continue;
}
Answer(a,b);
vector<int> v1;
vector<int> v2;
for(int i = 0; i < n; i++){
P[i] = 0;
}
for(int x : v){
P[x] = 1;
}
P[b] = 0;
for(int x : v){
if(ask(a, x)){
v1.push_back(x);
} else {
v2.push_back(x);
}
}
solvetree(v1, n);
solvetree(v2, n);
return;
}
}
void solve2(int n){
vector<int> v;
for(int i = 0; i < n; i++){
v.push_back(i);
}
solvetree(v, n);
}
void Detect(int T, int N) {
srand(48);
for(int i = 0; i < N; i++){
P[i] = 0;
}
if(T == 1){
solve1(N);
} else if(T >= 2){
solve2(N);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
8 ms |
376 KB |
Output is correct |
3 |
Correct |
10 ms |
540 KB |
Output is correct |
4 |
Correct |
8 ms |
540 KB |
Output is correct |
5 |
Correct |
8 ms |
540 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
91 ms |
780 KB |
Output is correct |
2 |
Correct |
47 ms |
804 KB |
Output is correct |
3 |
Correct |
51 ms |
956 KB |
Output is correct |
4 |
Correct |
81 ms |
1024 KB |
Output is correct |
5 |
Correct |
140 ms |
1024 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
296 ms |
1156 KB |
Wrong Answer[5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
107 ms |
1156 KB |
Wrong Answer[5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
697 ms |
1280 KB |
Wrong Answer[5] |
2 |
Halted |
0 ms |
0 KB |
- |