답안 #579376

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
579376 2022-06-19T03:38:28 Z amunduzbaev Amusement Park (CEOI19_amusementpark) C++17
19 / 100
3000 ms 52440 KB
#include "bits/stdc++.h"
using namespace std;
 
#define ar array
typedef int64_t ll;
//~ #define int ll
 
const int N = 20;
const int P = 167;
const int mod = 119 << 23 | 1;
vector<int> edges[N], qwe[N];
int used[N], is[N][N];
 
signed main(){
	ios::sync_with_stdio(0); cin.tie(0);
	
	int n, m; cin>>n>>m;
	vector<ar<int, 2>> e(m);
	for(int i=0;i<m;i++){
		cin>>e[i][0]>>e[i][1];
		edges[e[i][0]].push_back(e[i][1]);
		edges[e[i][1]].push_back(e[i][0]);
		is[e[i][0]][e[i][1]] = 1;
	}
	
	for(int i=1;i<=n;i++) sort(edges[i].begin(), edges[i].end());
	
	vector<int> p(n);
	iota(p.begin(), p.end(), 1);
	set<vector<int>> ss;
	int res = 0;
	do{
		memset(used, 0, sizeof used);
		int cnt = 0;
		for(auto u : p){
			qwe[u].clear();
			for(auto x : edges[u]){
				if(used[x]) continue;
				qwe[u].push_back(x);
				if(!is[u][x]) cnt++;
			}
			
			used[u] = 1;
		}
		
		memset(used, 0, sizeof used);
		vector<int> t;
		function<void(int)> dfs = [&](int u){
			used[u] = 1;
			for(auto x : qwe[u]){
				if(used[x]) continue;
				dfs(x);
			}
			
			t.push_back(u);
		};
		
		for(int i=1;i<=n;i++){
			if(!used[i]) dfs(i);
		}
		
		reverse(t.begin(), t.end());
		//~ int hh = 0;
		//~ for(auto x : t){
			//~ hh = (hh * 1ll * P + x) % mod;
		//~ }
		
		if(!ss.count(t)){
			ss.insert(t);
			res = (res + cnt) % mod;
		}
	}while(next_permutation(p.begin(), p.end()));
	
	cout<<res<<"\n";
}
 
 
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 2 ms 212 KB Output is correct
26 Correct 2 ms 212 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 3 ms 340 KB Output is correct
29 Correct 4 ms 468 KB Output is correct
30 Correct 7 ms 596 KB Output is correct
31 Correct 5 ms 852 KB Output is correct
32 Correct 19 ms 316 KB Output is correct
33 Correct 17 ms 212 KB Output is correct
34 Correct 19 ms 376 KB Output is correct
35 Correct 24 ms 760 KB Output is correct
36 Correct 28 ms 1648 KB Output is correct
37 Correct 35 ms 2804 KB Output is correct
38 Correct 39 ms 4724 KB Output is correct
39 Correct 143 ms 212 KB Output is correct
40 Correct 164 ms 324 KB Output is correct
41 Correct 185 ms 456 KB Output is correct
42 Correct 223 ms 876 KB Output is correct
43 Correct 235 ms 3320 KB Output is correct
44 Correct 308 ms 6144 KB Output is correct
45 Correct 321 ms 13232 KB Output is correct
46 Correct 369 ms 25004 KB Output is correct
47 Correct 442 ms 39960 KB Output is correct
48 Correct 142 ms 340 KB Output is correct
49 Correct 193 ms 716 KB Output is correct
50 Correct 188 ms 772 KB Output is correct
51 Correct 176 ms 704 KB Output is correct
52 Correct 1504 ms 304 KB Output is correct
53 Correct 1865 ms 484 KB Output is correct
54 Correct 2096 ms 944 KB Output is correct
55 Correct 2269 ms 3788 KB Output is correct
56 Correct 2693 ms 20164 KB Output is correct
57 Execution timed out 3019 ms 52440 KB Time limit exceeded
58 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 2 ms 212 KB Output is correct
26 Correct 2 ms 212 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 3 ms 340 KB Output is correct
29 Correct 4 ms 468 KB Output is correct
30 Correct 7 ms 596 KB Output is correct
31 Correct 5 ms 852 KB Output is correct
32 Correct 19 ms 316 KB Output is correct
33 Correct 17 ms 212 KB Output is correct
34 Correct 19 ms 376 KB Output is correct
35 Correct 24 ms 760 KB Output is correct
36 Correct 28 ms 1648 KB Output is correct
37 Correct 35 ms 2804 KB Output is correct
38 Correct 39 ms 4724 KB Output is correct
39 Correct 143 ms 212 KB Output is correct
40 Correct 164 ms 324 KB Output is correct
41 Correct 185 ms 456 KB Output is correct
42 Correct 223 ms 876 KB Output is correct
43 Correct 235 ms 3320 KB Output is correct
44 Correct 308 ms 6144 KB Output is correct
45 Correct 321 ms 13232 KB Output is correct
46 Correct 369 ms 25004 KB Output is correct
47 Correct 442 ms 39960 KB Output is correct
48 Correct 142 ms 340 KB Output is correct
49 Correct 193 ms 716 KB Output is correct
50 Correct 188 ms 772 KB Output is correct
51 Correct 176 ms 704 KB Output is correct
52 Correct 1504 ms 304 KB Output is correct
53 Correct 1865 ms 484 KB Output is correct
54 Correct 2096 ms 944 KB Output is correct
55 Correct 2269 ms 3788 KB Output is correct
56 Correct 2693 ms 20164 KB Output is correct
57 Execution timed out 3019 ms 52440 KB Time limit exceeded
58 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 2 ms 212 KB Output is correct
26 Correct 2 ms 212 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 3 ms 340 KB Output is correct
29 Correct 4 ms 468 KB Output is correct
30 Correct 7 ms 596 KB Output is correct
31 Correct 5 ms 852 KB Output is correct
32 Correct 19 ms 316 KB Output is correct
33 Correct 17 ms 212 KB Output is correct
34 Correct 19 ms 376 KB Output is correct
35 Correct 24 ms 760 KB Output is correct
36 Correct 28 ms 1648 KB Output is correct
37 Correct 35 ms 2804 KB Output is correct
38 Correct 39 ms 4724 KB Output is correct
39 Correct 143 ms 212 KB Output is correct
40 Correct 164 ms 324 KB Output is correct
41 Correct 185 ms 456 KB Output is correct
42 Correct 223 ms 876 KB Output is correct
43 Correct 235 ms 3320 KB Output is correct
44 Correct 308 ms 6144 KB Output is correct
45 Correct 321 ms 13232 KB Output is correct
46 Correct 369 ms 25004 KB Output is correct
47 Correct 442 ms 39960 KB Output is correct
48 Correct 142 ms 340 KB Output is correct
49 Correct 193 ms 716 KB Output is correct
50 Correct 188 ms 772 KB Output is correct
51 Correct 176 ms 704 KB Output is correct
52 Correct 1504 ms 304 KB Output is correct
53 Correct 1865 ms 484 KB Output is correct
54 Correct 2096 ms 944 KB Output is correct
55 Correct 2269 ms 3788 KB Output is correct
56 Correct 2693 ms 20164 KB Output is correct
57 Execution timed out 3019 ms 52440 KB Time limit exceeded
58 Halted 0 ms 0 KB -