Submission #531770

# Submission time Handle Problem Language Result Execution time Memory
531770 2022-03-01T13:03:09 Z Yazan_Alattar Amusement Park (CEOI19_amusementpark) C++14
19 / 100
3000 ms 128712 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
const int M = 2007;
const ll inf = 1e18;
const ll mod = 998244353;
const double pi = acos(-1);
const int dx[] = {0, -1, 0, 1}, dy[] = {1, 0, -1, 0};
const int block = 320;
 
map <string, bool> vist;
ll n, m, a[M], b[M], p[M], pos[M], ans;
 
int main(){
	cin >> n >> m;
	for(int i = 1; i <= m; ++i) cin >> a[i] >> b[i];
	
	for(int i = 1; i <= n; ++i) p[i] = i;
	do{
		for(int i = 1; i <= n; ++i) pos[p[i]] = i;
		
		string s = "";
		ll cost = 0;
		for(int i = 1; i <= m; ++i){
			if(pos[a[i]] > pos[b[i]]) s += '1', ++cost;
			else s += '0';
		}
		
		if(!vist[s]) ans = (ans + cost) % mod;
		vist[s] = 1;
	}
	while(next_permutation(p + 1, p + n + 1));
	
	cout << ans << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 292 KB Output is correct
16 Correct 1 ms 292 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 292 KB Output is correct
16 Correct 1 ms 292 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 3 ms 204 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 3 ms 332 KB Output is correct
30 Correct 4 ms 588 KB Output is correct
31 Correct 4 ms 844 KB Output is correct
32 Correct 5 ms 292 KB Output is correct
33 Correct 10 ms 204 KB Output is correct
34 Correct 16 ms 596 KB Output is correct
35 Correct 19 ms 692 KB Output is correct
36 Correct 22 ms 1432 KB Output is correct
37 Correct 29 ms 3208 KB Output is correct
38 Correct 35 ms 5316 KB Output is correct
39 Correct 44 ms 292 KB Output is correct
40 Correct 80 ms 308 KB Output is correct
41 Correct 102 ms 368 KB Output is correct
42 Correct 154 ms 1056 KB Output is correct
43 Correct 193 ms 3400 KB Output is correct
44 Correct 234 ms 6844 KB Output is correct
45 Correct 265 ms 15284 KB Output is correct
46 Correct 324 ms 28468 KB Output is correct
47 Correct 353 ms 45668 KB Output is correct
48 Correct 88 ms 316 KB Output is correct
49 Correct 122 ms 580 KB Output is correct
50 Correct 126 ms 604 KB Output is correct
51 Correct 137 ms 580 KB Output is correct
52 Correct 496 ms 288 KB Output is correct
53 Correct 950 ms 348 KB Output is correct
54 Correct 1275 ms 852 KB Output is correct
55 Correct 1800 ms 3776 KB Output is correct
56 Correct 2192 ms 22992 KB Output is correct
57 Correct 2555 ms 59976 KB Output is correct
58 Execution timed out 3079 ms 128712 KB Time limit exceeded
59 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 292 KB Output is correct
16 Correct 1 ms 292 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 3 ms 204 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 3 ms 332 KB Output is correct
30 Correct 4 ms 588 KB Output is correct
31 Correct 4 ms 844 KB Output is correct
32 Correct 5 ms 292 KB Output is correct
33 Correct 10 ms 204 KB Output is correct
34 Correct 16 ms 596 KB Output is correct
35 Correct 19 ms 692 KB Output is correct
36 Correct 22 ms 1432 KB Output is correct
37 Correct 29 ms 3208 KB Output is correct
38 Correct 35 ms 5316 KB Output is correct
39 Correct 44 ms 292 KB Output is correct
40 Correct 80 ms 308 KB Output is correct
41 Correct 102 ms 368 KB Output is correct
42 Correct 154 ms 1056 KB Output is correct
43 Correct 193 ms 3400 KB Output is correct
44 Correct 234 ms 6844 KB Output is correct
45 Correct 265 ms 15284 KB Output is correct
46 Correct 324 ms 28468 KB Output is correct
47 Correct 353 ms 45668 KB Output is correct
48 Correct 88 ms 316 KB Output is correct
49 Correct 122 ms 580 KB Output is correct
50 Correct 126 ms 604 KB Output is correct
51 Correct 137 ms 580 KB Output is correct
52 Correct 496 ms 288 KB Output is correct
53 Correct 950 ms 348 KB Output is correct
54 Correct 1275 ms 852 KB Output is correct
55 Correct 1800 ms 3776 KB Output is correct
56 Correct 2192 ms 22992 KB Output is correct
57 Correct 2555 ms 59976 KB Output is correct
58 Execution timed out 3079 ms 128712 KB Time limit exceeded
59 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 292 KB Output is correct
16 Correct 1 ms 292 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 3 ms 204 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 3 ms 332 KB Output is correct
30 Correct 4 ms 588 KB Output is correct
31 Correct 4 ms 844 KB Output is correct
32 Correct 5 ms 292 KB Output is correct
33 Correct 10 ms 204 KB Output is correct
34 Correct 16 ms 596 KB Output is correct
35 Correct 19 ms 692 KB Output is correct
36 Correct 22 ms 1432 KB Output is correct
37 Correct 29 ms 3208 KB Output is correct
38 Correct 35 ms 5316 KB Output is correct
39 Correct 44 ms 292 KB Output is correct
40 Correct 80 ms 308 KB Output is correct
41 Correct 102 ms 368 KB Output is correct
42 Correct 154 ms 1056 KB Output is correct
43 Correct 193 ms 3400 KB Output is correct
44 Correct 234 ms 6844 KB Output is correct
45 Correct 265 ms 15284 KB Output is correct
46 Correct 324 ms 28468 KB Output is correct
47 Correct 353 ms 45668 KB Output is correct
48 Correct 88 ms 316 KB Output is correct
49 Correct 122 ms 580 KB Output is correct
50 Correct 126 ms 604 KB Output is correct
51 Correct 137 ms 580 KB Output is correct
52 Correct 496 ms 288 KB Output is correct
53 Correct 950 ms 348 KB Output is correct
54 Correct 1275 ms 852 KB Output is correct
55 Correct 1800 ms 3776 KB Output is correct
56 Correct 2192 ms 22992 KB Output is correct
57 Correct 2555 ms 59976 KB Output is correct
58 Execution timed out 3079 ms 128712 KB Time limit exceeded
59 Halted 0 ms 0 KB -