Submission #579377

# Submission time Handle Problem Language Result Execution time Memory
579377 2022-06-19T03:40:01 Z amunduzbaev Amusement Park (CEOI19_amusementpark) C++17
19 / 100
184 ms 5916 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 = 487;
const int mod = 1e9 + 9;
vector<int> edges[N], qwe[N];
int used[N], is[N][N], cur[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<int> ss;
	int res = 0;
	do{
		memset(used, 0, sizeof used);
		int cnt = 0;
		for(auto u : p){
			cur[u] = 0;
			qwe[u].clear();
			for(auto x : edges[u]){
				if(used[x]) continue;
				qwe[u].push_back(x);
				cur[u] |= (1 << x);
				if(!is[u][x]) cnt++;
			}
			
			used[u] = 1;
		}
		
		int hh = 0;
		for(int i=1;i<=n;i++){
			hh = (hh * 1ll * P + cur[i]) % mod;
		}
		
		if(!ss.count(hh)){
			ss.insert(hh);
			res = (res + cnt) % mod;
		}
	}while(next_permutation(p.begin(), p.end()));
	
	cout<<res<<"\n";
}
 

# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 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 1 ms 288 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 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 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 444 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 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 1 ms 288 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 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 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 444 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 2 ms 212 KB Output is correct
27 Correct 2 ms 212 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 3 ms 468 KB Output is correct
31 Correct 3 ms 468 KB Output is correct
32 Correct 7 ms 320 KB Output is correct
33 Correct 9 ms 320 KB Output is correct
34 Correct 11 ms 340 KB Output is correct
35 Correct 14 ms 488 KB Output is correct
36 Correct 15 ms 808 KB Output is correct
37 Correct 20 ms 1400 KB Output is correct
38 Correct 25 ms 2096 KB Output is correct
39 Correct 57 ms 296 KB Output is correct
40 Correct 79 ms 324 KB Output is correct
41 Correct 96 ms 360 KB Output is correct
42 Correct 106 ms 460 KB Output is correct
43 Correct 127 ms 1572 KB Output is correct
44 Correct 149 ms 2700 KB Output is correct
45 Incorrect 184 ms 5916 KB Output isn't correct
46 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 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 1 ms 288 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 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 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 444 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 2 ms 212 KB Output is correct
27 Correct 2 ms 212 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 3 ms 468 KB Output is correct
31 Correct 3 ms 468 KB Output is correct
32 Correct 7 ms 320 KB Output is correct
33 Correct 9 ms 320 KB Output is correct
34 Correct 11 ms 340 KB Output is correct
35 Correct 14 ms 488 KB Output is correct
36 Correct 15 ms 808 KB Output is correct
37 Correct 20 ms 1400 KB Output is correct
38 Correct 25 ms 2096 KB Output is correct
39 Correct 57 ms 296 KB Output is correct
40 Correct 79 ms 324 KB Output is correct
41 Correct 96 ms 360 KB Output is correct
42 Correct 106 ms 460 KB Output is correct
43 Correct 127 ms 1572 KB Output is correct
44 Correct 149 ms 2700 KB Output is correct
45 Incorrect 184 ms 5916 KB Output isn't correct
46 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 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 1 ms 288 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 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 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 444 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 2 ms 212 KB Output is correct
27 Correct 2 ms 212 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 3 ms 468 KB Output is correct
31 Correct 3 ms 468 KB Output is correct
32 Correct 7 ms 320 KB Output is correct
33 Correct 9 ms 320 KB Output is correct
34 Correct 11 ms 340 KB Output is correct
35 Correct 14 ms 488 KB Output is correct
36 Correct 15 ms 808 KB Output is correct
37 Correct 20 ms 1400 KB Output is correct
38 Correct 25 ms 2096 KB Output is correct
39 Correct 57 ms 296 KB Output is correct
40 Correct 79 ms 324 KB Output is correct
41 Correct 96 ms 360 KB Output is correct
42 Correct 106 ms 460 KB Output is correct
43 Correct 127 ms 1572 KB Output is correct
44 Correct 149 ms 2700 KB Output is correct
45 Incorrect 184 ms 5916 KB Output isn't correct
46 Halted 0 ms 0 KB -