Submission #203794

# Submission time Handle Problem Language Result Execution time Memory
203794 2020-02-22T07:54:18 Z dndhk Amusement Park (CEOI19_amusementpark) C++14
19 / 100
3000 ms 167924 KB
#include <bits/stdc++.h>

#define pb push_back

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;

const int MAX_N = 30;
const ll MOD = 998244353;

int N, M;
vector<int> gp[MAX_N+1];
vector<pii> edge;
int c[MAX_N+1], idx[MAX_N+1];
ll ans;

set<ll> st;
ll chk(){
	for(int i=1; i<=N; i++)	while(!gp[i].empty())	gp[i].pop_back();
	ll now = 0;
	for(int i=0; i<M; i++){
		now = (now << 1);
		int u = edge[i].first, v = edge[i].second;
		if(idx[u]<idx[v]){
			int t = u; u = v; v = t;
			now+=1LL;
		}
		gp[u].pb(v);
	}
	if(st.find(now)!=st.end())	return 0;
	//cout<<now<<endl;
	st.insert(now); return now;
}

int per[MAX_N+1];

int main(){
	scanf("%d%d", &N, &M);
	for(int i=0; i<M; i++){
		int x, y; scanf("%d%d", &x, &y); edge.pb({x, y});
	}
	for(int i=0; i<N; i++){
		per[i] = i+1;
	}
	while(1){
		for(int i=0; i<N; i++)	idx[per[i]] = i;
		ans = (ans + __builtin_popcountll(chk())) % MOD;
		if(!next_permutation(per, per+N))	break;
	}
	cout<<ans;
	return 0;
}

Compilation message

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:40:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &M);
  ~~~~~^~~~~~~~~~~~~~~~
amusementpark.cpp:42:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int x, y; scanf("%d%d", &x, &y); edge.pb({x, y});
             ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 256 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
19 Correct 5 ms 256 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 5 ms 256 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 6 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 256 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
19 Correct 5 ms 256 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 5 ms 256 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 6 ms 376 KB Output is correct
25 Correct 5 ms 256 KB Output is correct
26 Correct 6 ms 380 KB Output is correct
27 Correct 6 ms 376 KB Output is correct
28 Correct 6 ms 376 KB Output is correct
29 Correct 6 ms 376 KB Output is correct
30 Correct 7 ms 504 KB Output is correct
31 Correct 8 ms 504 KB Output is correct
32 Correct 8 ms 380 KB Output is correct
33 Correct 10 ms 376 KB Output is correct
34 Correct 13 ms 376 KB Output is correct
35 Correct 16 ms 504 KB Output is correct
36 Correct 20 ms 888 KB Output is correct
37 Correct 25 ms 1400 KB Output is correct
38 Correct 31 ms 2168 KB Output is correct
39 Correct 38 ms 256 KB Output is correct
40 Correct 55 ms 376 KB Output is correct
41 Correct 72 ms 376 KB Output is correct
42 Correct 93 ms 504 KB Output is correct
43 Correct 124 ms 1656 KB Output is correct
44 Correct 151 ms 2936 KB Output is correct
45 Correct 186 ms 5880 KB Output is correct
46 Correct 249 ms 10872 KB Output is correct
47 Correct 297 ms 17400 KB Output is correct
48 Correct 53 ms 376 KB Output is correct
49 Correct 88 ms 632 KB Output is correct
50 Correct 89 ms 504 KB Output is correct
51 Correct 90 ms 504 KB Output is correct
52 Correct 376 ms 408 KB Output is correct
53 Correct 604 ms 504 KB Output is correct
54 Correct 814 ms 888 KB Output is correct
55 Correct 1060 ms 1996 KB Output is correct
56 Correct 1362 ms 8952 KB Output is correct
57 Correct 1718 ms 22900 KB Output is correct
58 Correct 2176 ms 48832 KB Output is correct
59 Correct 2704 ms 94940 KB Output is correct
60 Execution timed out 3083 ms 167924 KB Time limit exceeded
61 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 256 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
19 Correct 5 ms 256 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 5 ms 256 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 6 ms 376 KB Output is correct
25 Correct 5 ms 256 KB Output is correct
26 Correct 6 ms 380 KB Output is correct
27 Correct 6 ms 376 KB Output is correct
28 Correct 6 ms 376 KB Output is correct
29 Correct 6 ms 376 KB Output is correct
30 Correct 7 ms 504 KB Output is correct
31 Correct 8 ms 504 KB Output is correct
32 Correct 8 ms 380 KB Output is correct
33 Correct 10 ms 376 KB Output is correct
34 Correct 13 ms 376 KB Output is correct
35 Correct 16 ms 504 KB Output is correct
36 Correct 20 ms 888 KB Output is correct
37 Correct 25 ms 1400 KB Output is correct
38 Correct 31 ms 2168 KB Output is correct
39 Correct 38 ms 256 KB Output is correct
40 Correct 55 ms 376 KB Output is correct
41 Correct 72 ms 376 KB Output is correct
42 Correct 93 ms 504 KB Output is correct
43 Correct 124 ms 1656 KB Output is correct
44 Correct 151 ms 2936 KB Output is correct
45 Correct 186 ms 5880 KB Output is correct
46 Correct 249 ms 10872 KB Output is correct
47 Correct 297 ms 17400 KB Output is correct
48 Correct 53 ms 376 KB Output is correct
49 Correct 88 ms 632 KB Output is correct
50 Correct 89 ms 504 KB Output is correct
51 Correct 90 ms 504 KB Output is correct
52 Correct 376 ms 408 KB Output is correct
53 Correct 604 ms 504 KB Output is correct
54 Correct 814 ms 888 KB Output is correct
55 Correct 1060 ms 1996 KB Output is correct
56 Correct 1362 ms 8952 KB Output is correct
57 Correct 1718 ms 22900 KB Output is correct
58 Correct 2176 ms 48832 KB Output is correct
59 Correct 2704 ms 94940 KB Output is correct
60 Execution timed out 3083 ms 167924 KB Time limit exceeded
61 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 256 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
19 Correct 5 ms 256 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 5 ms 256 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 6 ms 376 KB Output is correct
25 Correct 5 ms 256 KB Output is correct
26 Correct 6 ms 380 KB Output is correct
27 Correct 6 ms 376 KB Output is correct
28 Correct 6 ms 376 KB Output is correct
29 Correct 6 ms 376 KB Output is correct
30 Correct 7 ms 504 KB Output is correct
31 Correct 8 ms 504 KB Output is correct
32 Correct 8 ms 380 KB Output is correct
33 Correct 10 ms 376 KB Output is correct
34 Correct 13 ms 376 KB Output is correct
35 Correct 16 ms 504 KB Output is correct
36 Correct 20 ms 888 KB Output is correct
37 Correct 25 ms 1400 KB Output is correct
38 Correct 31 ms 2168 KB Output is correct
39 Correct 38 ms 256 KB Output is correct
40 Correct 55 ms 376 KB Output is correct
41 Correct 72 ms 376 KB Output is correct
42 Correct 93 ms 504 KB Output is correct
43 Correct 124 ms 1656 KB Output is correct
44 Correct 151 ms 2936 KB Output is correct
45 Correct 186 ms 5880 KB Output is correct
46 Correct 249 ms 10872 KB Output is correct
47 Correct 297 ms 17400 KB Output is correct
48 Correct 53 ms 376 KB Output is correct
49 Correct 88 ms 632 KB Output is correct
50 Correct 89 ms 504 KB Output is correct
51 Correct 90 ms 504 KB Output is correct
52 Correct 376 ms 408 KB Output is correct
53 Correct 604 ms 504 KB Output is correct
54 Correct 814 ms 888 KB Output is correct
55 Correct 1060 ms 1996 KB Output is correct
56 Correct 1362 ms 8952 KB Output is correct
57 Correct 1718 ms 22900 KB Output is correct
58 Correct 2176 ms 48832 KB Output is correct
59 Correct 2704 ms 94940 KB Output is correct
60 Execution timed out 3083 ms 167924 KB Time limit exceeded
61 Halted 0 ms 0 KB -