#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define int long long
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);
int sumc = 0;
const int mod = 998244353;
set<vector<int>> svi;
do {
vector<int> real;
int curs = 0;
for (auto a : vpii) {
if ((ht[a.first] > ht[a.second])) {
curs++;
real.emplace_back(a.second);
real.emplace_back(a.first);
}
real.emplace_back(a.first);
real.emplace_back(a.second);
}
auto it = svi.insert(real);
if (it.second) {
sumc += curs;
sumc %= mod;
}
} while (next_permutation(ht.begin(), ht.end()));
cout << sumc << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 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 |
1 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 |
1 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 |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 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 |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
712 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 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 |
1 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 |
1 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 |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 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 |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
712 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
2 ms |
464 KB |
Output is correct |
28 |
Correct |
2 ms |
604 KB |
Output is correct |
29 |
Correct |
3 ms |
860 KB |
Output is correct |
30 |
Correct |
4 ms |
1884 KB |
Output is correct |
31 |
Correct |
5 ms |
3164 KB |
Output is correct |
32 |
Correct |
6 ms |
348 KB |
Output is correct |
33 |
Correct |
10 ms |
500 KB |
Output is correct |
34 |
Correct |
17 ms |
868 KB |
Output is correct |
35 |
Correct |
23 ms |
2120 KB |
Output is correct |
36 |
Correct |
30 ms |
6128 KB |
Output is correct |
37 |
Correct |
40 ms |
15436 KB |
Output is correct |
38 |
Correct |
55 ms |
30036 KB |
Output is correct |
39 |
Correct |
49 ms |
348 KB |
Output is correct |
40 |
Correct |
93 ms |
348 KB |
Output is correct |
41 |
Correct |
136 ms |
852 KB |
Output is correct |
42 |
Correct |
190 ms |
2820 KB |
Output is correct |
43 |
Correct |
252 ms |
15868 KB |
Output is correct |
44 |
Correct |
313 ms |
34388 KB |
Output is correct |
45 |
Correct |
446 ms |
87380 KB |
Output is correct |
46 |
Correct |
547 ms |
187216 KB |
Output is correct |
47 |
Correct |
707 ms |
335432 KB |
Output is correct |
48 |
Correct |
78 ms |
460 KB |
Output is correct |
49 |
Correct |
156 ms |
2272 KB |
Output is correct |
50 |
Correct |
171 ms |
2168 KB |
Output is correct |
51 |
Correct |
176 ms |
2132 KB |
Output is correct |
52 |
Correct |
555 ms |
348 KB |
Output is correct |
53 |
Correct |
1122 ms |
596 KB |
Output is correct |
54 |
Correct |
1843 ms |
3156 KB |
Output is correct |
55 |
Correct |
2491 ms |
18004 KB |
Output is correct |
56 |
Execution timed out |
3047 ms |
110828 KB |
Time limit exceeded |
57 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 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 |
1 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 |
1 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 |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 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 |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
712 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
2 ms |
464 KB |
Output is correct |
28 |
Correct |
2 ms |
604 KB |
Output is correct |
29 |
Correct |
3 ms |
860 KB |
Output is correct |
30 |
Correct |
4 ms |
1884 KB |
Output is correct |
31 |
Correct |
5 ms |
3164 KB |
Output is correct |
32 |
Correct |
6 ms |
348 KB |
Output is correct |
33 |
Correct |
10 ms |
500 KB |
Output is correct |
34 |
Correct |
17 ms |
868 KB |
Output is correct |
35 |
Correct |
23 ms |
2120 KB |
Output is correct |
36 |
Correct |
30 ms |
6128 KB |
Output is correct |
37 |
Correct |
40 ms |
15436 KB |
Output is correct |
38 |
Correct |
55 ms |
30036 KB |
Output is correct |
39 |
Correct |
49 ms |
348 KB |
Output is correct |
40 |
Correct |
93 ms |
348 KB |
Output is correct |
41 |
Correct |
136 ms |
852 KB |
Output is correct |
42 |
Correct |
190 ms |
2820 KB |
Output is correct |
43 |
Correct |
252 ms |
15868 KB |
Output is correct |
44 |
Correct |
313 ms |
34388 KB |
Output is correct |
45 |
Correct |
446 ms |
87380 KB |
Output is correct |
46 |
Correct |
547 ms |
187216 KB |
Output is correct |
47 |
Correct |
707 ms |
335432 KB |
Output is correct |
48 |
Correct |
78 ms |
460 KB |
Output is correct |
49 |
Correct |
156 ms |
2272 KB |
Output is correct |
50 |
Correct |
171 ms |
2168 KB |
Output is correct |
51 |
Correct |
176 ms |
2132 KB |
Output is correct |
52 |
Correct |
555 ms |
348 KB |
Output is correct |
53 |
Correct |
1122 ms |
596 KB |
Output is correct |
54 |
Correct |
1843 ms |
3156 KB |
Output is correct |
55 |
Correct |
2491 ms |
18004 KB |
Output is correct |
56 |
Execution timed out |
3047 ms |
110828 KB |
Time limit exceeded |
57 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 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 |
1 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 |
1 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 |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 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 |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
712 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
2 ms |
464 KB |
Output is correct |
28 |
Correct |
2 ms |
604 KB |
Output is correct |
29 |
Correct |
3 ms |
860 KB |
Output is correct |
30 |
Correct |
4 ms |
1884 KB |
Output is correct |
31 |
Correct |
5 ms |
3164 KB |
Output is correct |
32 |
Correct |
6 ms |
348 KB |
Output is correct |
33 |
Correct |
10 ms |
500 KB |
Output is correct |
34 |
Correct |
17 ms |
868 KB |
Output is correct |
35 |
Correct |
23 ms |
2120 KB |
Output is correct |
36 |
Correct |
30 ms |
6128 KB |
Output is correct |
37 |
Correct |
40 ms |
15436 KB |
Output is correct |
38 |
Correct |
55 ms |
30036 KB |
Output is correct |
39 |
Correct |
49 ms |
348 KB |
Output is correct |
40 |
Correct |
93 ms |
348 KB |
Output is correct |
41 |
Correct |
136 ms |
852 KB |
Output is correct |
42 |
Correct |
190 ms |
2820 KB |
Output is correct |
43 |
Correct |
252 ms |
15868 KB |
Output is correct |
44 |
Correct |
313 ms |
34388 KB |
Output is correct |
45 |
Correct |
446 ms |
87380 KB |
Output is correct |
46 |
Correct |
547 ms |
187216 KB |
Output is correct |
47 |
Correct |
707 ms |
335432 KB |
Output is correct |
48 |
Correct |
78 ms |
460 KB |
Output is correct |
49 |
Correct |
156 ms |
2272 KB |
Output is correct |
50 |
Correct |
171 ms |
2168 KB |
Output is correct |
51 |
Correct |
176 ms |
2132 KB |
Output is correct |
52 |
Correct |
555 ms |
348 KB |
Output is correct |
53 |
Correct |
1122 ms |
596 KB |
Output is correct |
54 |
Correct |
1843 ms |
3156 KB |
Output is correct |
55 |
Correct |
2491 ms |
18004 KB |
Output is correct |
56 |
Execution timed out |
3047 ms |
110828 KB |
Time limit exceeded |
57 |
Halted |
0 ms |
0 KB |
- |