# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
125372 |
2019-07-05T07:08:55 Z |
구재현(#3066) |
Park (JOI17_park) |
C++14 |
|
795 ms |
932 KB |
#include "park.h"
#include <bits/stdc++.h>
using namespace std;
bool ask(int s, int e, vector<int> v){
if(s > e) swap(s, e);
int Place[1400] = {};
v.push_back(s); v.push_back(e);
for(auto &i : v) Place[i] = 1;
return Ask(s, e, Place);
}
void dfs(vector<int> v){
if(v.size() == 1) return;
random_shuffle(v.begin(), v.end());
int r = v[0];
vector<int> adj;
int j = -1;
for(auto &i : v){
if(i == r) continue;
if(ask(i, r, {})){
j = i;
break;
}
}
vector<int> noj = v;
noj.erase(find(noj.begin(), noj.end(), j));
vector<int> ls, rs;
for(auto &i : v){
if(i == r || i == j) continue;
if(ask(r, i, noj) == 1) ls.push_back(i);
else rs.push_back(i);
}
Answer(min(r, j), max(r, j));
ls.push_back(r);
rs.push_back(j);
dfs(ls);
dfs(rs);
}
void dfs(int r, vector<int> v, int d){
if(v.size() == 1) return;
vector<int> adj;
int j = -1;
for(auto &i : v){
if(i == r) continue;
if(ask(i, r, {})){
j = i;
break;
}
}
vector<int> noj = v;
noj.erase(find(noj.begin(), noj.end(), j));
vector<int> ls, rs;
for(auto &i : v){
if(i == r || i == j) continue;
if(ask(r, i, noj) == 1) ls.push_back(i);
else rs.push_back(i);
}
Answer(min(r, j), max(r, j));
ls.push_back(r);
rs.push_back(j);
if(d <= 8) dfs(r, ls, d + 1);
else dfs(ls);
if(d <= 8) dfs(j, rs, d + 1);
else dfs(rs);
}
void Detect(int T, int N) {
srand(69696969);
vector<int> v(N);
iota(v.begin(), v.end(), 0);
dfs(0, v, 0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Wrong Answer[6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
352 ms |
816 KB |
Wrong Answer[5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
209 ms |
932 KB |
Wrong Answer[5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
191 ms |
764 KB |
Wrong Answer[5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
795 ms |
884 KB |
Wrong Answer[5] |
2 |
Halted |
0 ms |
0 KB |
- |