Submission #418657

# Submission time Handle Problem Language Result Execution time Memory
418657 2021-06-05T16:52:56 Z alishahali1382 Park (JOI17_park) C++14
67 / 100
492 ms 716 KB
#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));
			}
		}
	}

}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 485 ms 512 KB Output is correct
2 Correct 154 ms 460 KB Output is correct
3 Correct 207 ms 492 KB Output is correct
4 Correct 478 ms 584 KB Output is correct
5 Correct 490 ms 532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 243 ms 468 KB Output is correct
2 Correct 271 ms 476 KB Output is correct
3 Correct 272 ms 456 KB Output is correct
4 Correct 222 ms 472 KB Output is correct
5 Correct 293 ms 580 KB Output is correct
6 Correct 264 ms 460 KB Output is correct
7 Correct 250 ms 460 KB Output is correct
8 Correct 274 ms 472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 138 ms 332 KB Output is correct
2 Correct 307 ms 468 KB Output is correct
3 Correct 312 ms 460 KB Output is correct
4 Correct 355 ms 472 KB Output is correct
5 Correct 328 ms 488 KB Output is correct
6 Correct 356 ms 404 KB Output is correct
7 Correct 386 ms 460 KB Output is correct
8 Correct 315 ms 460 KB Output is correct
9 Correct 331 ms 468 KB Output is correct
10 Correct 362 ms 488 KB Output is correct
11 Correct 337 ms 480 KB Output is correct
12 Correct 293 ms 484 KB Output is correct
13 Correct 399 ms 468 KB Output is correct
14 Correct 331 ms 472 KB Output is correct
15 Correct 384 ms 464 KB Output is correct
16 Correct 263 ms 468 KB Output is correct
17 Correct 492 ms 524 KB Output is correct
18 Correct 340 ms 488 KB Output is correct
19 Correct 398 ms 500 KB Output is correct
20 Correct 317 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 716 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -