#include "park.h"
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;
const int inf=1000000010;
const ll INF=1000000000000001000LL;
const int mod=1000000007;
const int MAXN=1510, LOG=18;
static int Place[1400];
inline int ask(int u, int v){
if (u>v) swap(u, v);
Place[u]=Place[v]=1;
return Ask(u, v, Place);
}
inline void add_edge(int u, int v){
if (u>v) swap(u, v);
Answer(u, v);
}
int n, m, k, u, v, x, y, a, b, t;
int mark[MAXN];
int par[MAXN], h[MAXN];
vector<int> topol;
vector<int> G[MAXN];
void dfs(int node){
topol.pb(node);
for (int v:G[node]) dfs(v);
}
int GetPar(int v){
int dwn=0, up=topol.size();
while (up-dwn>1){
int mid=(dwn+up)>>1;
memset(Place, 0, sizeof(Place));
for (int i=0; i<mid; i++) Place[topol[i]]=1;
if (ask(0, v)) up=mid;
else dwn=mid;
}
par[v]=topol[dwn];
h[v]=h[par[v]]+1;
return par[v];
}
int GetUp(int v){
vector<int> bad;
for (int i=0; i<n; i++) if (i!=v && !mark[i]) bad.pb(i);
int dwn=0, up=bad.size();
while (up-dwn>1){
int mid=(dwn+up)>>1;
memcpy(Place, mark, sizeof(Place));
for (int i=0; i<mid; i++) Place[bad[i]]=1;
if (ask(0, v)) up=mid;
else dwn=mid;
}
return bad[dwn];
}
void Detect(int T, int _n){
assert(T==2 || T==3 || T==4);
n=_n;
mark[0]=1;
topol.pb(0);
vector<int> vec;
for (int i=1; i<n; i++) if (!mark[i]){
vec.pb(i);
while (vec.size()){
// debugv(vec)
int v=vec.back();
memcpy(Place, mark, sizeof(Place));
if (ask(0, v)){
add_edge(GetPar(v), v);
vec.pop_back();
mark[v]=1;
topol.pb(v);
// sort(all(topol), [](int i, int j){
// return h[i]<h[j];
// });
}
else{
vec.pb(GetUp(v));
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
440 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
442 ms |
500 KB |
Output is correct |
2 |
Correct |
118 ms |
488 KB |
Output is correct |
3 |
Correct |
166 ms |
496 KB |
Output is correct |
4 |
Correct |
423 ms |
492 KB |
Output is correct |
5 |
Correct |
425 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
203 ms |
440 KB |
Output is correct |
2 |
Correct |
216 ms |
500 KB |
Output is correct |
3 |
Correct |
231 ms |
452 KB |
Output is correct |
4 |
Correct |
195 ms |
332 KB |
Output is correct |
5 |
Correct |
249 ms |
452 KB |
Output is correct |
6 |
Correct |
225 ms |
452 KB |
Output is correct |
7 |
Correct |
216 ms |
460 KB |
Output is correct |
8 |
Correct |
220 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
119 ms |
332 KB |
Output is correct |
2 |
Correct |
274 ms |
452 KB |
Output is correct |
3 |
Correct |
283 ms |
452 KB |
Output is correct |
4 |
Correct |
317 ms |
444 KB |
Output is correct |
5 |
Correct |
311 ms |
460 KB |
Output is correct |
6 |
Correct |
288 ms |
476 KB |
Output is correct |
7 |
Correct |
358 ms |
460 KB |
Output is correct |
8 |
Correct |
282 ms |
456 KB |
Output is correct |
9 |
Correct |
305 ms |
332 KB |
Output is correct |
10 |
Correct |
316 ms |
460 KB |
Output is correct |
11 |
Correct |
305 ms |
460 KB |
Output is correct |
12 |
Correct |
269 ms |
464 KB |
Output is correct |
13 |
Correct |
376 ms |
460 KB |
Output is correct |
14 |
Correct |
280 ms |
460 KB |
Output is correct |
15 |
Correct |
384 ms |
460 KB |
Output is correct |
16 |
Correct |
232 ms |
436 KB |
Output is correct |
17 |
Correct |
430 ms |
508 KB |
Output is correct |
18 |
Correct |
302 ms |
460 KB |
Output is correct |
19 |
Correct |
397 ms |
468 KB |
Output is correct |
20 |
Correct |
299 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
588 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |