답안 #118196

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
118196 2019-06-18T10:37:53 Z scanhex Meetings (JOI19_meetings) C++17
100 / 100
1728 ms 8292 KB
#include "meetings.h"
#ifdef ONPC
#include "grader.h"
#endif
#include<bits/stdc++.h>
using namespace std;

map<vector<int>,int>mp;
int que(int a,int b,int c){
	vector<int>v={a,b,c};
	sort(v.begin(),v.end());
	if(mp.count(v))return mp[v];
	return mp[v]=Query(v[0],v[1],v[2]);
}
using uint=unsigned int;
uint seed=239239239;
uint xrand(){
	seed^=seed<<2;
	seed^=seed>>7;
	seed^=seed<<7;
	return seed;
}
mt19937 rnd(228);
void solve(vector<int>v){
//	cerr<<v.size()<<'\n';
//	for(auto&x:v)
//		cerr<<x<<' ';
//	cerr<<'\n';
	if(v.size()<=1)return;
	shuffle(v.begin(),v.end(),rnd);
	int kek=v[0];
	if(v.size()>=100){
		kek=que(v[0],v[1],v[2]);
		swap(v[0],*find(v.begin(),v.end(),kek));
	}
	int cur=v[1];
	vector<int>nw={};
	for(int x:v){
		if(x==kek)continue;
		if(x==cur){
			nw.push_back(x);
			continue;
		}
		int mem=que(x,cur,kek);
		if(mem==kek)
			;
		else if(mem==cur)
			nw.push_back(x);
		else
			nw.push_back(x),cur=mem;
	}
	Bridge(min(kek,cur),max(kek,cur));
	solve(nw);
	set<int>nw1(nw.begin(),nw.end());
	vector<int>other;
	for(int x:v)
		if(!nw1.count(x))other.push_back(x);
	solve(other);
}
void Solve(int n) {
	mp.clear();
	vector<int>ord(n);
	iota(ord.begin(),ord.end(),0);
	solve(ord);
}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 2 ms 512 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 3 ms 512 KB Output is correct
21 Correct 3 ms 512 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 2 ms 512 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 3 ms 512 KB Output is correct
21 Correct 3 ms 512 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 20 ms 1024 KB Output is correct
28 Correct 13 ms 896 KB Output is correct
29 Correct 15 ms 896 KB Output is correct
30 Correct 13 ms 896 KB Output is correct
31 Correct 12 ms 768 KB Output is correct
32 Correct 20 ms 1152 KB Output is correct
33 Correct 22 ms 1280 KB Output is correct
34 Correct 20 ms 1152 KB Output is correct
35 Correct 20 ms 1152 KB Output is correct
36 Correct 15 ms 888 KB Output is correct
37 Correct 11 ms 768 KB Output is correct
38 Correct 10 ms 640 KB Output is correct
39 Correct 9 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1711 ms 5652 KB Output is correct
2 Correct 1616 ms 5892 KB Output is correct
3 Correct 1577 ms 5308 KB Output is correct
4 Correct 1728 ms 5856 KB Output is correct
5 Correct 990 ms 4852 KB Output is correct
6 Correct 733 ms 4760 KB Output is correct
7 Correct 978 ms 7252 KB Output is correct
8 Correct 1124 ms 7080 KB Output is correct
9 Correct 966 ms 7284 KB Output is correct
10 Correct 845 ms 6720 KB Output is correct
11 Correct 924 ms 6680 KB Output is correct
12 Correct 965 ms 4080 KB Output is correct
13 Correct 877 ms 4752 KB Output is correct
14 Correct 1121 ms 7064 KB Output is correct
15 Correct 1392 ms 7980 KB Output is correct
16 Correct 1349 ms 8292 KB Output is correct
17 Correct 1331 ms 7556 KB Output is correct
18 Correct 1248 ms 7456 KB Output is correct
19 Correct 1281 ms 7444 KB Output is correct
20 Correct 1190 ms 7804 KB Output is correct
21 Correct 1401 ms 8176 KB Output is correct
22 Correct 1218 ms 7112 KB Output is correct
23 Correct 1204 ms 6876 KB Output is correct
24 Correct 1314 ms 7720 KB Output is correct
25 Correct 1428 ms 7376 KB Output is correct
26 Correct 1360 ms 7100 KB Output is correct
27 Correct 1500 ms 7292 KB Output is correct
28 Correct 1118 ms 6768 KB Output is correct
29 Correct 833 ms 6764 KB Output is correct
30 Correct 968 ms 6824 KB Output is correct
31 Correct 864 ms 6612 KB Output is correct
32 Correct 908 ms 3448 KB Output is correct
33 Correct 672 ms 3580 KB Output is correct
34 Correct 21 ms 1024 KB Output is correct
35 Correct 14 ms 896 KB Output is correct
36 Correct 16 ms 1024 KB Output is correct
37 Correct 13 ms 896 KB Output is correct
38 Correct 13 ms 768 KB Output is correct
39 Correct 20 ms 1024 KB Output is correct
40 Correct 23 ms 1152 KB Output is correct
41 Correct 21 ms 1272 KB Output is correct
42 Correct 21 ms 1152 KB Output is correct
43 Correct 17 ms 1024 KB Output is correct
44 Correct 11 ms 768 KB Output is correct
45 Correct 11 ms 796 KB Output is correct
46 Correct 10 ms 768 KB Output is correct
47 Correct 3 ms 512 KB Output is correct
48 Correct 2 ms 512 KB Output is correct
49 Correct 3 ms 512 KB Output is correct
50 Correct 2 ms 384 KB Output is correct
51 Correct 3 ms 512 KB Output is correct
52 Correct 3 ms 512 KB Output is correct
53 Correct 3 ms 384 KB Output is correct
54 Correct 3 ms 512 KB Output is correct
55 Correct 2 ms 384 KB Output is correct
56 Correct 2 ms 384 KB Output is correct
57 Correct 2 ms 384 KB Output is correct
58 Correct 2 ms 384 KB Output is correct
59 Correct 2 ms 384 KB Output is correct
60 Correct 2 ms 384 KB Output is correct
61 Correct 2 ms 384 KB Output is correct
62 Correct 2 ms 384 KB Output is correct
63 Correct 2 ms 256 KB Output is correct
64 Correct 2 ms 256 KB Output is correct
65 Correct 2 ms 304 KB Output is correct
66 Correct 2 ms 384 KB Output is correct
67 Correct 2 ms 256 KB Output is correct
68 Correct 2 ms 384 KB Output is correct
69 Correct 2 ms 256 KB Output is correct
70 Correct 2 ms 384 KB Output is correct
71 Correct 2 ms 256 KB Output is correct
72 Correct 2 ms 384 KB Output is correct