#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<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";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
1 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 |
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 |
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 |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
1 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 |
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 |
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 |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
604 KB |
Output is correct |
25 |
Correct |
1 ms |
344 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 |
604 KB |
Output is correct |
30 |
Correct |
4 ms |
1116 KB |
Output is correct |
31 |
Correct |
4 ms |
1884 KB |
Output is correct |
32 |
Correct |
6 ms |
348 KB |
Output is correct |
33 |
Correct |
10 ms |
464 KB |
Output is correct |
34 |
Correct |
16 ms |
604 KB |
Output is correct |
35 |
Correct |
21 ms |
1340 KB |
Output is correct |
36 |
Correct |
26 ms |
3680 KB |
Output is correct |
37 |
Correct |
36 ms |
8784 KB |
Output is correct |
38 |
Correct |
46 ms |
16720 KB |
Output is correct |
39 |
Correct |
51 ms |
348 KB |
Output is correct |
40 |
Correct |
89 ms |
344 KB |
Output is correct |
41 |
Correct |
138 ms |
600 KB |
Output is correct |
42 |
Correct |
179 ms |
1620 KB |
Output is correct |
43 |
Correct |
245 ms |
9044 KB |
Output is correct |
44 |
Correct |
301 ms |
19284 KB |
Output is correct |
45 |
Correct |
377 ms |
47924 KB |
Output is correct |
46 |
Correct |
451 ms |
101716 KB |
Output is correct |
47 |
Correct |
608 ms |
180556 KB |
Output is correct |
48 |
Correct |
95 ms |
348 KB |
Output is correct |
49 |
Correct |
154 ms |
1360 KB |
Output is correct |
50 |
Correct |
169 ms |
1364 KB |
Output is correct |
51 |
Correct |
180 ms |
1332 KB |
Output is correct |
52 |
Correct |
578 ms |
344 KB |
Output is correct |
53 |
Correct |
1138 ms |
576 KB |
Output is correct |
54 |
Correct |
1851 ms |
1816 KB |
Output is correct |
55 |
Correct |
2417 ms |
10320 KB |
Output is correct |
56 |
Execution timed out |
3060 ms |
62580 KB |
Time limit exceeded |
57 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
1 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 |
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 |
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 |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
604 KB |
Output is correct |
25 |
Correct |
1 ms |
344 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 |
604 KB |
Output is correct |
30 |
Correct |
4 ms |
1116 KB |
Output is correct |
31 |
Correct |
4 ms |
1884 KB |
Output is correct |
32 |
Correct |
6 ms |
348 KB |
Output is correct |
33 |
Correct |
10 ms |
464 KB |
Output is correct |
34 |
Correct |
16 ms |
604 KB |
Output is correct |
35 |
Correct |
21 ms |
1340 KB |
Output is correct |
36 |
Correct |
26 ms |
3680 KB |
Output is correct |
37 |
Correct |
36 ms |
8784 KB |
Output is correct |
38 |
Correct |
46 ms |
16720 KB |
Output is correct |
39 |
Correct |
51 ms |
348 KB |
Output is correct |
40 |
Correct |
89 ms |
344 KB |
Output is correct |
41 |
Correct |
138 ms |
600 KB |
Output is correct |
42 |
Correct |
179 ms |
1620 KB |
Output is correct |
43 |
Correct |
245 ms |
9044 KB |
Output is correct |
44 |
Correct |
301 ms |
19284 KB |
Output is correct |
45 |
Correct |
377 ms |
47924 KB |
Output is correct |
46 |
Correct |
451 ms |
101716 KB |
Output is correct |
47 |
Correct |
608 ms |
180556 KB |
Output is correct |
48 |
Correct |
95 ms |
348 KB |
Output is correct |
49 |
Correct |
154 ms |
1360 KB |
Output is correct |
50 |
Correct |
169 ms |
1364 KB |
Output is correct |
51 |
Correct |
180 ms |
1332 KB |
Output is correct |
52 |
Correct |
578 ms |
344 KB |
Output is correct |
53 |
Correct |
1138 ms |
576 KB |
Output is correct |
54 |
Correct |
1851 ms |
1816 KB |
Output is correct |
55 |
Correct |
2417 ms |
10320 KB |
Output is correct |
56 |
Execution timed out |
3060 ms |
62580 KB |
Time limit exceeded |
57 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
1 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 |
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 |
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 |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
604 KB |
Output is correct |
25 |
Correct |
1 ms |
344 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 |
604 KB |
Output is correct |
30 |
Correct |
4 ms |
1116 KB |
Output is correct |
31 |
Correct |
4 ms |
1884 KB |
Output is correct |
32 |
Correct |
6 ms |
348 KB |
Output is correct |
33 |
Correct |
10 ms |
464 KB |
Output is correct |
34 |
Correct |
16 ms |
604 KB |
Output is correct |
35 |
Correct |
21 ms |
1340 KB |
Output is correct |
36 |
Correct |
26 ms |
3680 KB |
Output is correct |
37 |
Correct |
36 ms |
8784 KB |
Output is correct |
38 |
Correct |
46 ms |
16720 KB |
Output is correct |
39 |
Correct |
51 ms |
348 KB |
Output is correct |
40 |
Correct |
89 ms |
344 KB |
Output is correct |
41 |
Correct |
138 ms |
600 KB |
Output is correct |
42 |
Correct |
179 ms |
1620 KB |
Output is correct |
43 |
Correct |
245 ms |
9044 KB |
Output is correct |
44 |
Correct |
301 ms |
19284 KB |
Output is correct |
45 |
Correct |
377 ms |
47924 KB |
Output is correct |
46 |
Correct |
451 ms |
101716 KB |
Output is correct |
47 |
Correct |
608 ms |
180556 KB |
Output is correct |
48 |
Correct |
95 ms |
348 KB |
Output is correct |
49 |
Correct |
154 ms |
1360 KB |
Output is correct |
50 |
Correct |
169 ms |
1364 KB |
Output is correct |
51 |
Correct |
180 ms |
1332 KB |
Output is correct |
52 |
Correct |
578 ms |
344 KB |
Output is correct |
53 |
Correct |
1138 ms |
576 KB |
Output is correct |
54 |
Correct |
1851 ms |
1816 KB |
Output is correct |
55 |
Correct |
2417 ms |
10320 KB |
Output is correct |
56 |
Execution timed out |
3060 ms |
62580 KB |
Time limit exceeded |
57 |
Halted |
0 ms |
0 KB |
- |