#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
signed main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
int n, m;
cin >> n >> m;
vector<int> ht(n);
vector<pair<int, int>> vpii(m);
for (auto &a : vpii) {
cin >> a.first >> a.second;
a.first--, a.second--;
}
iota(ht.begin(), ht.end(), 0);
long long sumc = 0;
const int mod = 998244353;
set<long long> svi;
do {
long long val = 0;
int in = 0;
int curs = 0;
for (auto a : vpii) {
val *= 2;
if ((ht[a.first] > ht[a.second])) {
curs++;
curs %= mod;
val++;
}
}
auto it = svi.insert(val);
if (it.second) {
sumc += curs;
sumc %= mod;
}
} while (next_permutation(ht.begin(), ht.end()));
cout << sumc << "\n";
}
Compilation message
amusementpark.cpp: In function 'int main()':
amusementpark.cpp:21:9: warning: unused variable 'in' [-Wunused-variable]
21 | int in = 0;
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
460 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
460 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
460 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
604 KB |
Output is correct |
31 |
Correct |
1 ms |
604 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
452 KB |
Output is correct |
34 |
Correct |
2 ms |
352 KB |
Output is correct |
35 |
Correct |
4 ms |
604 KB |
Output is correct |
36 |
Correct |
5 ms |
860 KB |
Output is correct |
37 |
Correct |
7 ms |
1372 KB |
Output is correct |
38 |
Correct |
9 ms |
2324 KB |
Output is correct |
39 |
Correct |
6 ms |
456 KB |
Output is correct |
40 |
Correct |
8 ms |
348 KB |
Output is correct |
41 |
Correct |
14 ms |
348 KB |
Output is correct |
42 |
Correct |
20 ms |
604 KB |
Output is correct |
43 |
Correct |
33 ms |
1624 KB |
Output is correct |
44 |
Correct |
46 ms |
2900 KB |
Output is correct |
45 |
Correct |
65 ms |
5972 KB |
Output is correct |
46 |
Correct |
82 ms |
10836 KB |
Output is correct |
47 |
Correct |
104 ms |
17232 KB |
Output is correct |
48 |
Correct |
7 ms |
348 KB |
Output is correct |
49 |
Correct |
14 ms |
660 KB |
Output is correct |
50 |
Correct |
17 ms |
568 KB |
Output is correct |
51 |
Correct |
23 ms |
604 KB |
Output is correct |
52 |
Correct |
50 ms |
348 KB |
Output is correct |
53 |
Correct |
92 ms |
464 KB |
Output is correct |
54 |
Correct |
172 ms |
548 KB |
Output is correct |
55 |
Correct |
312 ms |
1712 KB |
Output is correct |
56 |
Correct |
412 ms |
8784 KB |
Output is correct |
57 |
Correct |
638 ms |
22788 KB |
Output is correct |
58 |
Correct |
851 ms |
48492 KB |
Output is correct |
59 |
Correct |
1208 ms |
94804 KB |
Output is correct |
60 |
Correct |
1632 ms |
170868 KB |
Output is correct |
61 |
Correct |
79 ms |
456 KB |
Output is correct |
62 |
Correct |
185 ms |
852 KB |
Output is correct |
63 |
Correct |
175 ms |
976 KB |
Output is correct |
64 |
Correct |
191 ms |
856 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
460 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
604 KB |
Output is correct |
31 |
Correct |
1 ms |
604 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
452 KB |
Output is correct |
34 |
Correct |
2 ms |
352 KB |
Output is correct |
35 |
Correct |
4 ms |
604 KB |
Output is correct |
36 |
Correct |
5 ms |
860 KB |
Output is correct |
37 |
Correct |
7 ms |
1372 KB |
Output is correct |
38 |
Correct |
9 ms |
2324 KB |
Output is correct |
39 |
Correct |
6 ms |
456 KB |
Output is correct |
40 |
Correct |
8 ms |
348 KB |
Output is correct |
41 |
Correct |
14 ms |
348 KB |
Output is correct |
42 |
Correct |
20 ms |
604 KB |
Output is correct |
43 |
Correct |
33 ms |
1624 KB |
Output is correct |
44 |
Correct |
46 ms |
2900 KB |
Output is correct |
45 |
Correct |
65 ms |
5972 KB |
Output is correct |
46 |
Correct |
82 ms |
10836 KB |
Output is correct |
47 |
Correct |
104 ms |
17232 KB |
Output is correct |
48 |
Correct |
7 ms |
348 KB |
Output is correct |
49 |
Correct |
14 ms |
660 KB |
Output is correct |
50 |
Correct |
17 ms |
568 KB |
Output is correct |
51 |
Correct |
23 ms |
604 KB |
Output is correct |
52 |
Correct |
50 ms |
348 KB |
Output is correct |
53 |
Correct |
92 ms |
464 KB |
Output is correct |
54 |
Correct |
172 ms |
548 KB |
Output is correct |
55 |
Correct |
312 ms |
1712 KB |
Output is correct |
56 |
Correct |
412 ms |
8784 KB |
Output is correct |
57 |
Correct |
638 ms |
22788 KB |
Output is correct |
58 |
Correct |
851 ms |
48492 KB |
Output is correct |
59 |
Correct |
1208 ms |
94804 KB |
Output is correct |
60 |
Correct |
1632 ms |
170868 KB |
Output is correct |
61 |
Correct |
79 ms |
456 KB |
Output is correct |
62 |
Correct |
185 ms |
852 KB |
Output is correct |
63 |
Correct |
175 ms |
976 KB |
Output is correct |
64 |
Correct |
191 ms |
856 KB |
Output is correct |
65 |
Execution timed out |
3091 ms |
7472 KB |
Time limit exceeded |
66 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
460 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
604 KB |
Output is correct |
31 |
Correct |
1 ms |
604 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
452 KB |
Output is correct |
34 |
Correct |
2 ms |
352 KB |
Output is correct |
35 |
Correct |
4 ms |
604 KB |
Output is correct |
36 |
Correct |
5 ms |
860 KB |
Output is correct |
37 |
Correct |
7 ms |
1372 KB |
Output is correct |
38 |
Correct |
9 ms |
2324 KB |
Output is correct |
39 |
Correct |
6 ms |
456 KB |
Output is correct |
40 |
Correct |
8 ms |
348 KB |
Output is correct |
41 |
Correct |
14 ms |
348 KB |
Output is correct |
42 |
Correct |
20 ms |
604 KB |
Output is correct |
43 |
Correct |
33 ms |
1624 KB |
Output is correct |
44 |
Correct |
46 ms |
2900 KB |
Output is correct |
45 |
Correct |
65 ms |
5972 KB |
Output is correct |
46 |
Correct |
82 ms |
10836 KB |
Output is correct |
47 |
Correct |
104 ms |
17232 KB |
Output is correct |
48 |
Correct |
7 ms |
348 KB |
Output is correct |
49 |
Correct |
14 ms |
660 KB |
Output is correct |
50 |
Correct |
17 ms |
568 KB |
Output is correct |
51 |
Correct |
23 ms |
604 KB |
Output is correct |
52 |
Correct |
50 ms |
348 KB |
Output is correct |
53 |
Correct |
92 ms |
464 KB |
Output is correct |
54 |
Correct |
172 ms |
548 KB |
Output is correct |
55 |
Correct |
312 ms |
1712 KB |
Output is correct |
56 |
Correct |
412 ms |
8784 KB |
Output is correct |
57 |
Correct |
638 ms |
22788 KB |
Output is correct |
58 |
Correct |
851 ms |
48492 KB |
Output is correct |
59 |
Correct |
1208 ms |
94804 KB |
Output is correct |
60 |
Correct |
1632 ms |
170868 KB |
Output is correct |
61 |
Correct |
79 ms |
456 KB |
Output is correct |
62 |
Correct |
185 ms |
852 KB |
Output is correct |
63 |
Correct |
175 ms |
976 KB |
Output is correct |
64 |
Correct |
191 ms |
856 KB |
Output is correct |
65 |
Execution timed out |
3091 ms |
7472 KB |
Time limit exceeded |
66 |
Halted |
0 ms |
0 KB |
- |