# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
568302 |
2022-05-25T07:47:50 Z |
blue |
Park (JOI17_park) |
C++17 |
|
161 ms |
31264 KB |
#include "park.h"
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vpii = vector<pii>;
#define sz(x) int(x.size())
int N;
const int maxN = 1400;
static int Place[maxN];
vi parent(maxN, 0);
vi inserted(maxN, 0);
bool ask(int A, int B, int Place[])
{
return Ask(min(A, B), max(A, B), Place);
}
void answer(int a, int b)
{
Answer(min(a, b), max(a, b));
}
bool connected(int u, int v)
{
for(int i = 0; i < N; i++)
Place[i] = 0;
Place[u] = Place[v] = 1;
return ask(u, v, Place);
}
void insert_node(int u, int a)
{
if(inserted[u]) return;
// cerr << "insert node " << u << ' ' << a << '\n';
if(connected(u, a))
{
parent[u] = a;
inserted[u] = 1;
return;
}
vi searchlist;
for(int i = 0; i < N; i++)
{
if(i == u || i == a) continue;
searchlist.push_back(i);
}
while(sz(searchlist) > 1)
{
int md = sz(searchlist)/2;
vi lft, rgt;
for(int i = 0; i < sz(searchlist); i++)
{
if(i < md)
lft.push_back(searchlist[i]);
else
rgt.push_back(searchlist[i]);
}
for(int i = 0; i < N; i++)
Place[i] = 0;
for(int f : rgt)
Place[f] = 1;
Place[u] = Place[a] = 1;
if(ask(u, a, Place))
searchlist = lft;
else
searchlist = rgt;
}
int z = searchlist[0];
insert_node(u, z);
insert_node(z, a);
}
void Detect(int T, int N_)
{
N = N_;
inserted[0] = 1;
for(int i = 1; i < N; i++)
insert_node(i, 0);
for(int i = 1; i < N; i++)
answer(i, parent[i]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
2900 KB |
Wrong Answer[5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
149 ms |
31200 KB |
Wrong Answer[5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
139 ms |
31176 KB |
Wrong Answer[5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
113 ms |
17588 KB |
Wrong Answer[5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
161 ms |
31264 KB |
Wrong Answer[5] |
2 |
Halted |
0 ms |
0 KB |
- |