#include "park.h"
#include <bits/stdc++.h>
using namespace std;
int N;
static int Place[1400];
bool Chk[1400];
int now;
vector <int> new_check;
vector <int> to_check;
vector <int> v[1400];
void solv(int s, int e)
{
for(int i=s;i<=e;i++) Place[to_check[i]]=0;
int val=Ask(0, now, Place);
if(val==1) return;
for(int i=s;i<=e;i++) Place[to_check[i]]=1;
if(s==e)
{
new_check.push_back(to_check[s]);
return;
}
int mid=(s+e)/2;
solv(s, mid);
solv(mid+1, e);
}
bool cmp1(int a, int b)
{
Place[a]=0;
int val=Ask(0, b, Place);
Place[a]=1;
return val==0;
}
vector <int> tree[1400];
vector <int> euler;
void dfs(int now, int pre)
{
euler.push_back(now);
for(int nxt : tree[now]) if(nxt!=pre)
{
dfs(nxt, now);
euler.push_back(now);
}
}
int solv_par_0(int now)
{
euler.clear();
dfs(0, -1);
int s=0, e=euler.size()-1;
for(int i=0;i<N;i++) Place[i]=0;
Place[now]=1;
while(s!=e)
{
int mid=(s+e)/2;
for(int i=s;i<=mid;i++) Place[euler[i]]=1;
int val=Ask(min(now, euler[s]), max(now, euler[s]), Place);
for(int i=s;i<=mid;i++) Place[euler[i]]=0;
if(val==0) s=mid+1;
else e=mid;
}
for(int i=0;i<N;i++) Place[i]=1;
tree[now].push_back(euler[s]);
tree[euler[s]].push_back(now);
v[now].push_back(euler[s]);
v[euler[s]].push_back(now);
return euler[s];
}
void solv_par(int now)
{
euler.clear();
dfs(0, -1);
for(int i=0;i<N;i++) Place[i]=0;
Place[now]=1;
set <int> s;
s.insert(euler.size());
vector <int> adj;
int cur=0;
bool jogun=true;
while(jogun)
{
jogun=false;
int nxt=euler.size();
//int nxt=*s.begin();
//s.erase(nxt);
if(cur==nxt)
{
cur++;
continue;
}
for(int i=cur;i<=nxt-1;i++) Place[euler[i]]=1;
int check_val=Ask(min(now, euler[cur]), max(now, euler[cur]), Place);
for(int i=cur;i<=nxt-1;i++) Place[euler[i]]=0;
if(check_val==0)
{
cur=nxt+1;
continue;
}
//s.insert(nxt);
int l=cur, r=nxt-1;
while(l!=r)
{
int mid=(l+r)/2;
for(int i=l;i<=mid;i++) Place[euler[i]]=1;
int val=Ask(min(now, euler[l]), max(now, euler[l]), Place);
for(int i=l;i<=mid;i++) Place[euler[i]]=0;
if(val==1) r=mid;
else l=mid+1;
}
//for(int i=l+1;i<euler.size();i++) if(euler[i]==euler[l]) s.insert(i);
adj.push_back(euler[l]);
cur=l+1;
}
tree[now].push_back(adj[0]);
tree[adj[0]].push_back(now);
for(int ele : adj)
{
v[ele].push_back(now);
v[now].push_back(ele);
}
}
void Detect(int T, int n) {
N=n;
Chk[0]=true;
for(int i=1;i<N;i++) to_check.push_back(i);
while(!to_check.empty())
{
for(int i=0;i<N;i++) Place[i]=1;
now=to_check.back();
to_check.pop_back();
new_check.push_back(now);
if(!to_check.empty()) solv(0, to_check.size()-1);
sort(new_check.begin(), new_check.end(), cmp1);
for(int ele : new_check) solv_par(ele);
for(int ele : new_check) Chk[ele]=true;
new_check.clear();
to_check.clear();
for(int i=0;i<N;i++) if(!Chk[i]) to_check.push_back(i);
}
for(int i=0;i<N;i++)
{
for(int ele : v[i]) if(ele<i) Answer(ele, i);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Wrong Answer[6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
317 ms |
512 KB |
Output is correct |
2 |
Correct |
153 ms |
516 KB |
Output is correct |
3 |
Correct |
171 ms |
520 KB |
Output is correct |
4 |
Correct |
312 ms |
528 KB |
Output is correct |
5 |
Correct |
326 ms |
580 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
173 ms |
468 KB |
Output is correct |
2 |
Correct |
181 ms |
468 KB |
Output is correct |
3 |
Correct |
193 ms |
492 KB |
Output is correct |
4 |
Correct |
188 ms |
460 KB |
Output is correct |
5 |
Correct |
214 ms |
616 KB |
Output is correct |
6 |
Correct |
180 ms |
500 KB |
Output is correct |
7 |
Correct |
190 ms |
592 KB |
Output is correct |
8 |
Correct |
184 ms |
760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
116 ms |
472 KB |
Output is correct |
2 |
Correct |
250 ms |
516 KB |
Output is correct |
3 |
Correct |
218 ms |
476 KB |
Output is correct |
4 |
Correct |
256 ms |
592 KB |
Output is correct |
5 |
Correct |
242 ms |
596 KB |
Output is correct |
6 |
Correct |
208 ms |
580 KB |
Output is correct |
7 |
Correct |
250 ms |
608 KB |
Output is correct |
8 |
Correct |
277 ms |
468 KB |
Output is correct |
9 |
Correct |
222 ms |
512 KB |
Output is correct |
10 |
Correct |
230 ms |
460 KB |
Output is correct |
11 |
Correct |
242 ms |
616 KB |
Output is correct |
12 |
Correct |
207 ms |
476 KB |
Output is correct |
13 |
Correct |
296 ms |
460 KB |
Output is correct |
14 |
Correct |
216 ms |
580 KB |
Output is correct |
15 |
Correct |
294 ms |
596 KB |
Output is correct |
16 |
Correct |
185 ms |
468 KB |
Output is correct |
17 |
Correct |
305 ms |
624 KB |
Output is correct |
18 |
Correct |
229 ms |
460 KB |
Output is correct |
19 |
Correct |
316 ms |
628 KB |
Output is correct |
20 |
Correct |
226 ms |
460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
220 ms |
460 KB |
Wrong Answer[6] |
2 |
Halted |
0 ms |
0 KB |
- |