답안 #384338

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
384338 2021-04-01T12:24:26 Z amoo_safar Meetings (JOI19_meetings) C++17
29 / 100
1994 ms 1024 KB
#include "meetings.h"

#include <bits/stdc++.h>
#define pb push_back
using namespace std;

mt19937 Amoo(chrono::steady_clock::now().time_since_epoch().count());

int rand(int bd){
	int res = bd;
	while(res == bd){
		res = uniform_int_distribution<int>(0, bd)(Amoo);
	}
	return res;
}
void bridge(int u, int v){
	if(u > v) swap(u, v);
	Bridge(u, v);
}

void solve(vector<int> V){
	// cerr << "! "; 
	// for(auto al : V) cerr << al << ' ';
	// cerr << '\n';
	int n = V.size();
	if(n == 1) return ;
	if(n == 2){
		bridge(V[0], V[1]);
		return ;
	}
	int a = rand(n);
	int b = a;
	while(b == a) b = rand(n);
	int c = a;
	while(c == a || c == b) c = rand(n);
	int rt = Query(V[a], V[b], V[c]);
	vector<int> Y;
	for(auto x : V) if(x != rt) Y.pb(x);
	vector<vector<int>> M;
	vector<int> mx;
	M.pb( {Y[0]} ); mx.pb(Y[0]);
	int res;
	for(int i = 1; i < (int) Y.size(); i++){
		int fl = 1;
		for(int j = 0; j < (int) mx.size(); j++){
			res = Query(rt, mx[j], Y[i]);
			if(res != rt){

				M[j].pb(Y[i]);
				if(res == Y[i])
					mx[j] = Y[i];
				fl = 0;
				break;
			}
		}
		if(fl){
			M.pb({Y[i]});
			mx.pb(Y[i]);
		}
	}
	for(auto u : mx)
		bridge(rt, u);
	for(auto I : M) solve(I);

}

void Solve(int N) {
	vector<int> A(N);
	iota(A.begin(), A.end(), 0);
	solve(A);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 492 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 2 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 492 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 2 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 10 ms 364 KB Output is correct
28 Correct 10 ms 364 KB Output is correct
29 Correct 10 ms 364 KB Output is correct
30 Correct 10 ms 364 KB Output is correct
31 Correct 10 ms 364 KB Output is correct
32 Correct 11 ms 364 KB Output is correct
33 Correct 20 ms 364 KB Output is correct
34 Correct 21 ms 364 KB Output is correct
35 Correct 18 ms 364 KB Output is correct
36 Correct 12 ms 364 KB Output is correct
37 Correct 11 ms 492 KB Output is correct
38 Correct 11 ms 492 KB Output is correct
39 Correct 12 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 745 ms 748 KB Output is correct
2 Correct 940 ms 876 KB Output is correct
3 Correct 957 ms 748 KB Output is correct
4 Correct 938 ms 876 KB Output is correct
5 Correct 843 ms 748 KB Output is correct
6 Correct 743 ms 888 KB Output is correct
7 Correct 910 ms 1024 KB Output is correct
8 Correct 962 ms 848 KB Output is correct
9 Correct 970 ms 744 KB Output is correct
10 Correct 955 ms 876 KB Output is correct
11 Correct 1077 ms 892 KB Output is correct
12 Correct 866 ms 876 KB Output is correct
13 Correct 782 ms 876 KB Output is correct
14 Correct 931 ms 884 KB Output is correct
15 Correct 882 ms 940 KB Output is correct
16 Correct 952 ms 876 KB Output is correct
17 Correct 891 ms 876 KB Output is correct
18 Incorrect 1994 ms 908 KB Wrong Answer [2]
19 Halted 0 ms 0 KB -