#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
int n, m, i, j, k, a, b, ans, s;
int mat[15][15];
vector<int> adj[15];
bool visited[15];
void dfs(int k, int x) {
visited[x] = true;
for (auto y : adj[x]) {
if (!visited[y] && (__builtin_popcount(s & (1 << y)) == k)) dfs(k, y);
}
}
int main() {
scanf("%d%d", &n, &m);
for (i=1; i <= n; ++i) for (j=1; j <= n; ++j) mat[i][j] = 0;
for (i=0; i < m; ++i) {
scanf("%d%d", &a, &b);
mat[a][b] = 1;
mat[b][a] = 1;
adj[a].push_back(b);
adj[b].push_back(a);
}
ans = 0;
for (i=1; i <= n; ++i) {
for (j=1; j <= n; ++j) {
if (i == j) continue;
for (k=1; k <= n; ++k) {
if (k == i || k == j) continue;
for (s=0; s < (1 << (n+1)); ++s) {
fill(visited, visited+n+1, false);
dfs(0, j);
if (!visited[i]) continue;
fill(visited, visited+n+1, false);
dfs(1, j);
if (!visited[k]) continue;
++ans;
break;
}
}
}
}
printf("%d\n", ans);
return 0;
}
Compilation message
count_triplets.cpp: In function 'int main()':
count_triplets.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
19 | scanf("%d%d", &n, &m);
| ~~~~~^~~~~~~~~~~~~~~~
count_triplets.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
23 | scanf("%d%d", &a, &b);
| ~~~~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
236 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Correct |
9 ms |
296 KB |
Output is correct |
7 |
Correct |
35 ms |
212 KB |
Output is correct |
8 |
Correct |
47 ms |
284 KB |
Output is correct |
9 |
Correct |
33 ms |
212 KB |
Output is correct |
10 |
Correct |
48 ms |
280 KB |
Output is correct |
11 |
Correct |
41 ms |
212 KB |
Output is correct |
12 |
Correct |
38 ms |
212 KB |
Output is correct |
13 |
Correct |
51 ms |
212 KB |
Output is correct |
14 |
Correct |
31 ms |
212 KB |
Output is correct |
15 |
Correct |
32 ms |
284 KB |
Output is correct |
16 |
Correct |
31 ms |
212 KB |
Output is correct |
17 |
Correct |
25 ms |
212 KB |
Output is correct |
18 |
Correct |
28 ms |
280 KB |
Output is correct |
19 |
Correct |
16 ms |
304 KB |
Output is correct |
20 |
Correct |
14 ms |
304 KB |
Output is correct |
21 |
Correct |
10 ms |
300 KB |
Output is correct |
22 |
Correct |
44 ms |
212 KB |
Output is correct |
23 |
Correct |
15 ms |
212 KB |
Output is correct |
24 |
Correct |
6 ms |
336 KB |
Output is correct |
25 |
Correct |
15 ms |
212 KB |
Output is correct |
26 |
Correct |
42 ms |
212 KB |
Output is correct |
27 |
Correct |
5 ms |
212 KB |
Output is correct |
28 |
Correct |
15 ms |
212 KB |
Output is correct |
29 |
Correct |
35 ms |
284 KB |
Output is correct |
30 |
Correct |
4 ms |
212 KB |
Output is correct |
31 |
Correct |
11 ms |
212 KB |
Output is correct |
32 |
Correct |
47 ms |
212 KB |
Output is correct |
33 |
Correct |
12 ms |
304 KB |
Output is correct |
34 |
Correct |
9 ms |
300 KB |
Output is correct |
35 |
Correct |
21 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
236 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Correct |
9 ms |
296 KB |
Output is correct |
7 |
Correct |
35 ms |
212 KB |
Output is correct |
8 |
Correct |
47 ms |
284 KB |
Output is correct |
9 |
Correct |
33 ms |
212 KB |
Output is correct |
10 |
Correct |
48 ms |
280 KB |
Output is correct |
11 |
Correct |
41 ms |
212 KB |
Output is correct |
12 |
Correct |
38 ms |
212 KB |
Output is correct |
13 |
Correct |
51 ms |
212 KB |
Output is correct |
14 |
Correct |
31 ms |
212 KB |
Output is correct |
15 |
Correct |
32 ms |
284 KB |
Output is correct |
16 |
Correct |
31 ms |
212 KB |
Output is correct |
17 |
Correct |
25 ms |
212 KB |
Output is correct |
18 |
Correct |
28 ms |
280 KB |
Output is correct |
19 |
Correct |
16 ms |
304 KB |
Output is correct |
20 |
Correct |
14 ms |
304 KB |
Output is correct |
21 |
Correct |
10 ms |
300 KB |
Output is correct |
22 |
Correct |
44 ms |
212 KB |
Output is correct |
23 |
Correct |
15 ms |
212 KB |
Output is correct |
24 |
Correct |
6 ms |
336 KB |
Output is correct |
25 |
Correct |
15 ms |
212 KB |
Output is correct |
26 |
Correct |
42 ms |
212 KB |
Output is correct |
27 |
Correct |
5 ms |
212 KB |
Output is correct |
28 |
Correct |
15 ms |
212 KB |
Output is correct |
29 |
Correct |
35 ms |
284 KB |
Output is correct |
30 |
Correct |
4 ms |
212 KB |
Output is correct |
31 |
Correct |
11 ms |
212 KB |
Output is correct |
32 |
Correct |
47 ms |
212 KB |
Output is correct |
33 |
Correct |
12 ms |
304 KB |
Output is correct |
34 |
Correct |
9 ms |
300 KB |
Output is correct |
35 |
Correct |
21 ms |
212 KB |
Output is correct |
36 |
Correct |
1 ms |
304 KB |
Output is correct |
37 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
38 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
440 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
236 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Correct |
9 ms |
296 KB |
Output is correct |
7 |
Correct |
35 ms |
212 KB |
Output is correct |
8 |
Correct |
47 ms |
284 KB |
Output is correct |
9 |
Correct |
33 ms |
212 KB |
Output is correct |
10 |
Correct |
48 ms |
280 KB |
Output is correct |
11 |
Correct |
41 ms |
212 KB |
Output is correct |
12 |
Correct |
38 ms |
212 KB |
Output is correct |
13 |
Correct |
51 ms |
212 KB |
Output is correct |
14 |
Correct |
31 ms |
212 KB |
Output is correct |
15 |
Correct |
32 ms |
284 KB |
Output is correct |
16 |
Correct |
31 ms |
212 KB |
Output is correct |
17 |
Correct |
25 ms |
212 KB |
Output is correct |
18 |
Correct |
28 ms |
280 KB |
Output is correct |
19 |
Correct |
16 ms |
304 KB |
Output is correct |
20 |
Correct |
14 ms |
304 KB |
Output is correct |
21 |
Correct |
10 ms |
300 KB |
Output is correct |
22 |
Correct |
44 ms |
212 KB |
Output is correct |
23 |
Correct |
15 ms |
212 KB |
Output is correct |
24 |
Correct |
6 ms |
336 KB |
Output is correct |
25 |
Correct |
15 ms |
212 KB |
Output is correct |
26 |
Correct |
42 ms |
212 KB |
Output is correct |
27 |
Correct |
5 ms |
212 KB |
Output is correct |
28 |
Correct |
15 ms |
212 KB |
Output is correct |
29 |
Correct |
35 ms |
284 KB |
Output is correct |
30 |
Correct |
4 ms |
212 KB |
Output is correct |
31 |
Correct |
11 ms |
212 KB |
Output is correct |
32 |
Correct |
47 ms |
212 KB |
Output is correct |
33 |
Correct |
12 ms |
304 KB |
Output is correct |
34 |
Correct |
9 ms |
300 KB |
Output is correct |
35 |
Correct |
21 ms |
212 KB |
Output is correct |
36 |
Correct |
1 ms |
304 KB |
Output is correct |
37 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
38 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
236 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Correct |
9 ms |
296 KB |
Output is correct |
7 |
Correct |
35 ms |
212 KB |
Output is correct |
8 |
Correct |
47 ms |
284 KB |
Output is correct |
9 |
Correct |
33 ms |
212 KB |
Output is correct |
10 |
Correct |
48 ms |
280 KB |
Output is correct |
11 |
Correct |
41 ms |
212 KB |
Output is correct |
12 |
Correct |
38 ms |
212 KB |
Output is correct |
13 |
Correct |
51 ms |
212 KB |
Output is correct |
14 |
Correct |
31 ms |
212 KB |
Output is correct |
15 |
Correct |
32 ms |
284 KB |
Output is correct |
16 |
Correct |
31 ms |
212 KB |
Output is correct |
17 |
Correct |
25 ms |
212 KB |
Output is correct |
18 |
Correct |
28 ms |
280 KB |
Output is correct |
19 |
Correct |
16 ms |
304 KB |
Output is correct |
20 |
Correct |
14 ms |
304 KB |
Output is correct |
21 |
Correct |
10 ms |
300 KB |
Output is correct |
22 |
Correct |
44 ms |
212 KB |
Output is correct |
23 |
Correct |
15 ms |
212 KB |
Output is correct |
24 |
Correct |
6 ms |
336 KB |
Output is correct |
25 |
Correct |
15 ms |
212 KB |
Output is correct |
26 |
Correct |
42 ms |
212 KB |
Output is correct |
27 |
Correct |
5 ms |
212 KB |
Output is correct |
28 |
Correct |
15 ms |
212 KB |
Output is correct |
29 |
Correct |
35 ms |
284 KB |
Output is correct |
30 |
Correct |
4 ms |
212 KB |
Output is correct |
31 |
Correct |
11 ms |
212 KB |
Output is correct |
32 |
Correct |
47 ms |
212 KB |
Output is correct |
33 |
Correct |
12 ms |
304 KB |
Output is correct |
34 |
Correct |
9 ms |
300 KB |
Output is correct |
35 |
Correct |
21 ms |
212 KB |
Output is correct |
36 |
Correct |
1 ms |
304 KB |
Output is correct |
37 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
38 |
Halted |
0 ms |
0 KB |
- |