#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;
const int N = 1e5 + 5;
set <long long> s;
pair <int, int> ed[N];
int pos[N];
int n,m;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> ed[i].fi >> ed[i].se;
}
if (n > 10)
return 0;
int ans = 0;
vector <int> id(n, 0); iota(id.begin(), id.end(), 1);
do {
for (int i = 0; i < n; i++)
pos[id[i]] = i;
long long res = 0;
int cnt = 0;
for (int i = 0; i < m; i++) {
int u = ed[i].fi;
int v = ed[i].se;
if (pos[u] > pos[v]) {
cnt++;
res |= (1LL << i);
}
}
if (s.find(res) == s.end()) {
ans += cnt;
s.insert(res);
}
} while (next_permutation(id.begin(), id.end()));
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
320 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
324 KB |
Output is correct |
13 |
Correct |
2 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
324 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
300 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
2 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
320 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
324 KB |
Output is correct |
13 |
Correct |
2 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
324 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
300 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
2 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
320 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
2 ms |
204 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
2 ms |
332 KB |
Output is correct |
29 |
Correct |
2 ms |
312 KB |
Output is correct |
30 |
Correct |
2 ms |
460 KB |
Output is correct |
31 |
Correct |
3 ms |
444 KB |
Output is correct |
32 |
Correct |
3 ms |
204 KB |
Output is correct |
33 |
Correct |
4 ms |
332 KB |
Output is correct |
34 |
Correct |
6 ms |
320 KB |
Output is correct |
35 |
Correct |
7 ms |
460 KB |
Output is correct |
36 |
Correct |
9 ms |
788 KB |
Output is correct |
37 |
Correct |
13 ms |
1336 KB |
Output is correct |
38 |
Correct |
17 ms |
2148 KB |
Output is correct |
39 |
Correct |
17 ms |
320 KB |
Output is correct |
40 |
Correct |
26 ms |
332 KB |
Output is correct |
41 |
Correct |
35 ms |
376 KB |
Output is correct |
42 |
Correct |
42 ms |
440 KB |
Output is correct |
43 |
Correct |
60 ms |
1616 KB |
Output is correct |
44 |
Correct |
71 ms |
2728 KB |
Output is correct |
45 |
Correct |
101 ms |
5820 KB |
Output is correct |
46 |
Correct |
132 ms |
10792 KB |
Output is correct |
47 |
Correct |
204 ms |
17344 KB |
Output is correct |
48 |
Correct |
24 ms |
320 KB |
Output is correct |
49 |
Correct |
39 ms |
504 KB |
Output is correct |
50 |
Correct |
42 ms |
496 KB |
Output is correct |
51 |
Correct |
38 ms |
460 KB |
Output is correct |
52 |
Correct |
190 ms |
204 KB |
Output is correct |
53 |
Correct |
291 ms |
320 KB |
Output is correct |
54 |
Correct |
402 ms |
604 KB |
Output is correct |
55 |
Correct |
475 ms |
1828 KB |
Output is correct |
56 |
Correct |
635 ms |
8724 KB |
Output is correct |
57 |
Correct |
837 ms |
22648 KB |
Output is correct |
58 |
Correct |
1071 ms |
48516 KB |
Output is correct |
59 |
Correct |
1474 ms |
94708 KB |
Output is correct |
60 |
Correct |
1976 ms |
170836 KB |
Output is correct |
61 |
Correct |
255 ms |
324 KB |
Output is correct |
62 |
Correct |
396 ms |
904 KB |
Output is correct |
63 |
Correct |
391 ms |
964 KB |
Output is correct |
64 |
Correct |
393 ms |
992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
320 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
324 KB |
Output is correct |
13 |
Correct |
2 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
324 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
300 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
2 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
320 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
2 ms |
204 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
2 ms |
332 KB |
Output is correct |
29 |
Correct |
2 ms |
312 KB |
Output is correct |
30 |
Correct |
2 ms |
460 KB |
Output is correct |
31 |
Correct |
3 ms |
444 KB |
Output is correct |
32 |
Correct |
3 ms |
204 KB |
Output is correct |
33 |
Correct |
4 ms |
332 KB |
Output is correct |
34 |
Correct |
6 ms |
320 KB |
Output is correct |
35 |
Correct |
7 ms |
460 KB |
Output is correct |
36 |
Correct |
9 ms |
788 KB |
Output is correct |
37 |
Correct |
13 ms |
1336 KB |
Output is correct |
38 |
Correct |
17 ms |
2148 KB |
Output is correct |
39 |
Correct |
17 ms |
320 KB |
Output is correct |
40 |
Correct |
26 ms |
332 KB |
Output is correct |
41 |
Correct |
35 ms |
376 KB |
Output is correct |
42 |
Correct |
42 ms |
440 KB |
Output is correct |
43 |
Correct |
60 ms |
1616 KB |
Output is correct |
44 |
Correct |
71 ms |
2728 KB |
Output is correct |
45 |
Correct |
101 ms |
5820 KB |
Output is correct |
46 |
Correct |
132 ms |
10792 KB |
Output is correct |
47 |
Correct |
204 ms |
17344 KB |
Output is correct |
48 |
Correct |
24 ms |
320 KB |
Output is correct |
49 |
Correct |
39 ms |
504 KB |
Output is correct |
50 |
Correct |
42 ms |
496 KB |
Output is correct |
51 |
Correct |
38 ms |
460 KB |
Output is correct |
52 |
Correct |
190 ms |
204 KB |
Output is correct |
53 |
Correct |
291 ms |
320 KB |
Output is correct |
54 |
Correct |
402 ms |
604 KB |
Output is correct |
55 |
Correct |
475 ms |
1828 KB |
Output is correct |
56 |
Correct |
635 ms |
8724 KB |
Output is correct |
57 |
Correct |
837 ms |
22648 KB |
Output is correct |
58 |
Correct |
1071 ms |
48516 KB |
Output is correct |
59 |
Correct |
1474 ms |
94708 KB |
Output is correct |
60 |
Correct |
1976 ms |
170836 KB |
Output is correct |
61 |
Correct |
255 ms |
324 KB |
Output is correct |
62 |
Correct |
396 ms |
904 KB |
Output is correct |
63 |
Correct |
391 ms |
964 KB |
Output is correct |
64 |
Correct |
393 ms |
992 KB |
Output is correct |
65 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
66 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
320 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
324 KB |
Output is correct |
13 |
Correct |
2 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
324 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
300 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
2 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
320 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
2 ms |
204 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
2 ms |
332 KB |
Output is correct |
29 |
Correct |
2 ms |
312 KB |
Output is correct |
30 |
Correct |
2 ms |
460 KB |
Output is correct |
31 |
Correct |
3 ms |
444 KB |
Output is correct |
32 |
Correct |
3 ms |
204 KB |
Output is correct |
33 |
Correct |
4 ms |
332 KB |
Output is correct |
34 |
Correct |
6 ms |
320 KB |
Output is correct |
35 |
Correct |
7 ms |
460 KB |
Output is correct |
36 |
Correct |
9 ms |
788 KB |
Output is correct |
37 |
Correct |
13 ms |
1336 KB |
Output is correct |
38 |
Correct |
17 ms |
2148 KB |
Output is correct |
39 |
Correct |
17 ms |
320 KB |
Output is correct |
40 |
Correct |
26 ms |
332 KB |
Output is correct |
41 |
Correct |
35 ms |
376 KB |
Output is correct |
42 |
Correct |
42 ms |
440 KB |
Output is correct |
43 |
Correct |
60 ms |
1616 KB |
Output is correct |
44 |
Correct |
71 ms |
2728 KB |
Output is correct |
45 |
Correct |
101 ms |
5820 KB |
Output is correct |
46 |
Correct |
132 ms |
10792 KB |
Output is correct |
47 |
Correct |
204 ms |
17344 KB |
Output is correct |
48 |
Correct |
24 ms |
320 KB |
Output is correct |
49 |
Correct |
39 ms |
504 KB |
Output is correct |
50 |
Correct |
42 ms |
496 KB |
Output is correct |
51 |
Correct |
38 ms |
460 KB |
Output is correct |
52 |
Correct |
190 ms |
204 KB |
Output is correct |
53 |
Correct |
291 ms |
320 KB |
Output is correct |
54 |
Correct |
402 ms |
604 KB |
Output is correct |
55 |
Correct |
475 ms |
1828 KB |
Output is correct |
56 |
Correct |
635 ms |
8724 KB |
Output is correct |
57 |
Correct |
837 ms |
22648 KB |
Output is correct |
58 |
Correct |
1071 ms |
48516 KB |
Output is correct |
59 |
Correct |
1474 ms |
94708 KB |
Output is correct |
60 |
Correct |
1976 ms |
170836 KB |
Output is correct |
61 |
Correct |
255 ms |
324 KB |
Output is correct |
62 |
Correct |
396 ms |
904 KB |
Output is correct |
63 |
Correct |
391 ms |
964 KB |
Output is correct |
64 |
Correct |
393 ms |
992 KB |
Output is correct |
65 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
66 |
Halted |
0 ms |
0 KB |
- |