#include "park.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=1405;
namespace park{
int N,Place[maxn],vis[maxn],a[maxn];
vector<int> edge[maxn];
void add(int u){
while(true){
memset(Place,0,sizeof(Place));
for(int i=0;i<N;i++) Place[i]=a[i];
Place[u]=true;
if(Ask(0,u,Place)) break;
int l=0,r=N-1,v=-1;
while(l<=r){
int mid=(l+r)>>1;
memset(Place,0,sizeof(Place));
for(int i=0;i<N;i++) Place[i]=(a[i] || i<=mid);
Place[u]=1;
if(Ask(0,u,Place)) v=mid,r=mid-1;
else l=mid+1;
}
add(v);
}
vector<int> root;
root.push_back(0);
while(!root.empty()){
int x=root.back();root.pop_back();
if(a[x]==3) continue;
memset(vis,0,sizeof(vis));
vector<int> d;
function<void(int)> dfs = [&](int u){
vis[u]=1;
d.push_back(u);
for(int v:edge[u]) if(!vis[v] && a[v]!=3) dfs(v);
};
dfs(x);
memset(Place,0,sizeof(Place));
for(int v:d) Place[v]=1;
Place[u]=1;
if(!Ask(min(u,x),max(u,x),Place)) continue;
int l=0,r=(int)d.size()-1,v=-1;
while(l<=r){
int mid=(l+r)>>1;
memset(Place,0,sizeof(Place));
for(int i=0;i<=mid;i++) Place[d[i]]=1;
Place[u]=1;
if(Ask(min(u,x),max(u,x),Place)) v=d[mid],r=mid-1;
else l=mid+1;
}
for(int nxt:edge[v]) if(a[nxt]!=3) root.push_back(nxt);
edge[u].push_back(v);
edge[v].push_back(u);
Answer(min(u,v),max(u,v));
a[v]=3;
}
for(int i=0;i<N;i++) a[i]=(a[i] || (i==u));
}
void Detect(int T, int n) {
a[0]=1;N=n;
for(int i=1;i<N;i++) if(!a[i]) add(i);
}
}
void Detect(int T, int N) {
park::Detect(T,N);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
7 ms |
348 KB |
Output is correct |
3 |
Correct |
6 ms |
348 KB |
Output is correct |
4 |
Correct |
20 ms |
348 KB |
Output is correct |
5 |
Correct |
58 ms |
536 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
270 ms |
928 KB |
Output is correct |
2 |
Correct |
121 ms |
600 KB |
Output is correct |
3 |
Correct |
148 ms |
600 KB |
Output is correct |
4 |
Correct |
267 ms |
940 KB |
Output is correct |
5 |
Correct |
264 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
124 ms |
612 KB |
Output is correct |
2 |
Correct |
129 ms |
588 KB |
Output is correct |
3 |
Correct |
135 ms |
764 KB |
Output is correct |
4 |
Correct |
120 ms |
612 KB |
Output is correct |
5 |
Correct |
149 ms |
628 KB |
Output is correct |
6 |
Correct |
135 ms |
860 KB |
Output is correct |
7 |
Correct |
127 ms |
596 KB |
Output is correct |
8 |
Correct |
133 ms |
848 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
73 ms |
580 KB |
Output is correct |
2 |
Correct |
179 ms |
592 KB |
Output is correct |
3 |
Correct |
171 ms |
604 KB |
Output is correct |
4 |
Correct |
188 ms |
580 KB |
Output is correct |
5 |
Correct |
195 ms |
600 KB |
Output is correct |
6 |
Correct |
209 ms |
600 KB |
Output is correct |
7 |
Correct |
206 ms |
600 KB |
Output is correct |
8 |
Correct |
172 ms |
592 KB |
Output is correct |
9 |
Correct |
172 ms |
608 KB |
Output is correct |
10 |
Correct |
196 ms |
848 KB |
Output is correct |
11 |
Correct |
192 ms |
628 KB |
Output is correct |
12 |
Correct |
162 ms |
612 KB |
Output is correct |
13 |
Correct |
220 ms |
604 KB |
Output is correct |
14 |
Correct |
180 ms |
604 KB |
Output is correct |
15 |
Correct |
242 ms |
604 KB |
Output is correct |
16 |
Correct |
136 ms |
844 KB |
Output is correct |
17 |
Correct |
262 ms |
648 KB |
Output is correct |
18 |
Correct |
193 ms |
628 KB |
Output is correct |
19 |
Correct |
237 ms |
880 KB |
Output is correct |
20 |
Correct |
181 ms |
596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
226 ms |
600 KB |
Output is correct |
2 |
Correct |
207 ms |
844 KB |
Output is correct |
3 |
Correct |
164 ms |
828 KB |
Output is correct |
4 |
Correct |
198 ms |
612 KB |
Output is correct |
5 |
Correct |
225 ms |
628 KB |
Output is correct |
6 |
Correct |
256 ms |
680 KB |
Output is correct |
7 |
Correct |
221 ms |
608 KB |
Output is correct |
8 |
Correct |
217 ms |
664 KB |
Output is correct |
9 |
Correct |
207 ms |
640 KB |
Output is correct |
10 |
Correct |
172 ms |
632 KB |
Output is correct |
11 |
Correct |
186 ms |
640 KB |
Output is correct |
12 |
Correct |
218 ms |
648 KB |
Output is correct |
13 |
Correct |
174 ms |
600 KB |
Output is correct |
14 |
Correct |
219 ms |
604 KB |
Output is correct |
15 |
Correct |
191 ms |
600 KB |
Output is correct |
16 |
Correct |
134 ms |
600 KB |
Output is correct |
17 |
Correct |
262 ms |
700 KB |
Output is correct |
18 |
Correct |
182 ms |
620 KB |
Output is correct |