#pragma GCC optimize("O3,Ofast,unroll-loops")
#pragma GCC target("avx2,bmi")
#include <bits/stdc++.h>
#define lli long long int
#define ld long double
#define pb push_back
#define MP make_pair
#define REP(i, n) for(int i = 0; (i) < (n); (i)++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
void fastio() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
const int N = 55;
const int INF = 1e9 + 500;
int n, m;
array<vector<int>, N> adj;
array<int, N> vis;
inline bool dfs(int node, int l, int t) {
if(l == node) return 0;
if(node == t) return 1;
vis[node] = 1;
for(auto c : adj[node]) {
if(vis[c]) continue;
if(dfs(c, l, t)) {
return 1;
}
}
return 0;
}
void solve() {
cin >> n >> m;
REP(i, m) {
int u, v;
cin >> u >> v;
adj[u].pb(v);
adj[v].pb(u);
}
int ans = 0;
for(int i = 1; i<=n; i++) {
for(int j = 1; j <= n; j++) {
for(int k = 1; k <= n; k++) {
if(i == j || j == k || i == k) continue;
bool f = 1;
for(int l = 1; l <= n; l++) {
if(l == j) continue;
fill(vis.begin(), vis.begin() + n + 1, 0);
if(dfs(i, l, j)) continue;
fill(vis.begin(), vis.begin() + n + 1, 0);
if(dfs(k, l, j)) continue;
f = 0;
break;
}
ans += f;
}
}
}
cout << ans << "\n";
}
signed main() {
fastio();
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
500 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 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 |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
360 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
600 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
344 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 |
344 KB |
Output is correct |
23 |
Correct |
0 ms |
456 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 |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
372 KB |
Output is correct |
31 |
Correct |
1 ms |
344 KB |
Output is correct |
32 |
Correct |
0 ms |
600 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
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 |
1 ms |
500 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 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 |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
360 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
600 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
344 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 |
344 KB |
Output is correct |
23 |
Correct |
0 ms |
456 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 |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
372 KB |
Output is correct |
31 |
Correct |
1 ms |
344 KB |
Output is correct |
32 |
Correct |
0 ms |
600 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
36 |
Correct |
2 ms |
348 KB |
Output is correct |
37 |
Correct |
6 ms |
460 KB |
Output is correct |
38 |
Correct |
339 ms |
428 KB |
Output is correct |
39 |
Correct |
589 ms |
344 KB |
Output is correct |
40 |
Correct |
616 ms |
596 KB |
Output is correct |
41 |
Correct |
7 ms |
344 KB |
Output is correct |
42 |
Correct |
7 ms |
348 KB |
Output is correct |
43 |
Correct |
8 ms |
460 KB |
Output is correct |
44 |
Correct |
9 ms |
348 KB |
Output is correct |
45 |
Correct |
12 ms |
348 KB |
Output is correct |
46 |
Correct |
12 ms |
460 KB |
Output is correct |
47 |
Correct |
0 ms |
348 KB |
Output is correct |
48 |
Correct |
4 ms |
348 KB |
Output is correct |
49 |
Correct |
3 ms |
348 KB |
Output is correct |
50 |
Correct |
2 ms |
464 KB |
Output is correct |
51 |
Correct |
349 ms |
348 KB |
Output is correct |
52 |
Correct |
179 ms |
436 KB |
Output is correct |
53 |
Correct |
438 ms |
344 KB |
Output is correct |
54 |
Correct |
504 ms |
436 KB |
Output is correct |
55 |
Correct |
534 ms |
592 KB |
Output is correct |
56 |
Correct |
468 ms |
440 KB |
Output is correct |
57 |
Correct |
282 ms |
452 KB |
Output is correct |
58 |
Correct |
315 ms |
440 KB |
Output is correct |
59 |
Correct |
272 ms |
684 KB |
Output is correct |
60 |
Correct |
116 ms |
596 KB |
Output is correct |
61 |
Correct |
57 ms |
344 KB |
Output is correct |
62 |
Correct |
20 ms |
344 KB |
Output is correct |
63 |
Correct |
335 ms |
436 KB |
Output is correct |
64 |
Correct |
254 ms |
344 KB |
Output is correct |
65 |
Correct |
221 ms |
436 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
604 KB |
Execution killed with signal 11 |
2 |
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 |
1 ms |
500 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 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 |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
360 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
600 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
344 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 |
344 KB |
Output is correct |
23 |
Correct |
0 ms |
456 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 |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
372 KB |
Output is correct |
31 |
Correct |
1 ms |
344 KB |
Output is correct |
32 |
Correct |
0 ms |
600 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
36 |
Correct |
2 ms |
348 KB |
Output is correct |
37 |
Correct |
6 ms |
460 KB |
Output is correct |
38 |
Correct |
339 ms |
428 KB |
Output is correct |
39 |
Correct |
589 ms |
344 KB |
Output is correct |
40 |
Correct |
616 ms |
596 KB |
Output is correct |
41 |
Correct |
7 ms |
344 KB |
Output is correct |
42 |
Correct |
7 ms |
348 KB |
Output is correct |
43 |
Correct |
8 ms |
460 KB |
Output is correct |
44 |
Correct |
9 ms |
348 KB |
Output is correct |
45 |
Correct |
12 ms |
348 KB |
Output is correct |
46 |
Correct |
12 ms |
460 KB |
Output is correct |
47 |
Correct |
0 ms |
348 KB |
Output is correct |
48 |
Correct |
4 ms |
348 KB |
Output is correct |
49 |
Correct |
3 ms |
348 KB |
Output is correct |
50 |
Correct |
2 ms |
464 KB |
Output is correct |
51 |
Correct |
349 ms |
348 KB |
Output is correct |
52 |
Correct |
179 ms |
436 KB |
Output is correct |
53 |
Correct |
438 ms |
344 KB |
Output is correct |
54 |
Correct |
504 ms |
436 KB |
Output is correct |
55 |
Correct |
534 ms |
592 KB |
Output is correct |
56 |
Correct |
468 ms |
440 KB |
Output is correct |
57 |
Correct |
282 ms |
452 KB |
Output is correct |
58 |
Correct |
315 ms |
440 KB |
Output is correct |
59 |
Correct |
272 ms |
684 KB |
Output is correct |
60 |
Correct |
116 ms |
596 KB |
Output is correct |
61 |
Correct |
57 ms |
344 KB |
Output is correct |
62 |
Correct |
20 ms |
344 KB |
Output is correct |
63 |
Correct |
335 ms |
436 KB |
Output is correct |
64 |
Correct |
254 ms |
344 KB |
Output is correct |
65 |
Correct |
221 ms |
436 KB |
Output is correct |
66 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
67 |
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 |
1 ms |
500 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 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 |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
360 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
600 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
344 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 |
344 KB |
Output is correct |
23 |
Correct |
0 ms |
456 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 |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
372 KB |
Output is correct |
31 |
Correct |
1 ms |
344 KB |
Output is correct |
32 |
Correct |
0 ms |
600 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
36 |
Correct |
2 ms |
348 KB |
Output is correct |
37 |
Correct |
6 ms |
460 KB |
Output is correct |
38 |
Correct |
339 ms |
428 KB |
Output is correct |
39 |
Correct |
589 ms |
344 KB |
Output is correct |
40 |
Correct |
616 ms |
596 KB |
Output is correct |
41 |
Correct |
7 ms |
344 KB |
Output is correct |
42 |
Correct |
7 ms |
348 KB |
Output is correct |
43 |
Correct |
8 ms |
460 KB |
Output is correct |
44 |
Correct |
9 ms |
348 KB |
Output is correct |
45 |
Correct |
12 ms |
348 KB |
Output is correct |
46 |
Correct |
12 ms |
460 KB |
Output is correct |
47 |
Correct |
0 ms |
348 KB |
Output is correct |
48 |
Correct |
4 ms |
348 KB |
Output is correct |
49 |
Correct |
3 ms |
348 KB |
Output is correct |
50 |
Correct |
2 ms |
464 KB |
Output is correct |
51 |
Correct |
349 ms |
348 KB |
Output is correct |
52 |
Correct |
179 ms |
436 KB |
Output is correct |
53 |
Correct |
438 ms |
344 KB |
Output is correct |
54 |
Correct |
504 ms |
436 KB |
Output is correct |
55 |
Correct |
534 ms |
592 KB |
Output is correct |
56 |
Correct |
468 ms |
440 KB |
Output is correct |
57 |
Correct |
282 ms |
452 KB |
Output is correct |
58 |
Correct |
315 ms |
440 KB |
Output is correct |
59 |
Correct |
272 ms |
684 KB |
Output is correct |
60 |
Correct |
116 ms |
596 KB |
Output is correct |
61 |
Correct |
57 ms |
344 KB |
Output is correct |
62 |
Correct |
20 ms |
344 KB |
Output is correct |
63 |
Correct |
335 ms |
436 KB |
Output is correct |
64 |
Correct |
254 ms |
344 KB |
Output is correct |
65 |
Correct |
221 ms |
436 KB |
Output is correct |
66 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
67 |
Halted |
0 ms |
0 KB |
- |