Submission #1043276

# Submission time Handle Problem Language Result Execution time Memory
1043276 2024-08-04T07:23:49 Z vjudge1 Duathlon (APIO18_duathlon) C++17
16 / 100
1000 ms 1476 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int N = 105;
int n, m;
vector<int> g[N];
bool vis[N], possible[N][N][N];

void dfs(int v, int y, int z){
    if (v == z) return;
    vis[v] = 1;
    for (int u : g[v])
        if (!vis[u]) dfs(u, y, z);
}

int main(){
    cin >> n >> m;
    for (int i = 0; i < m; i ++){
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    int total = n * (n - 1) * (n - 2);
    for (int u = 1; u <= n; u ++){
        for (int v = 1; v <= n; v ++){
            for (int e = 1; e <= n; e ++){
                memset(vis, 0, sizeof vis);
                dfs(u, v, e);
                if (vis[v])
                    possible[u][v][e] = 1;
            }
        }
    }

    for (int c = 1; c <= n; c ++){
        for (int s = 1; s <= n; s ++){
            for (int f = 1; f <= n; f ++){
                if (c == s or c == f or s == f) continue;
                bool bad = 0;
                for (int v = 1; v <= n; v ++){
                    if (v == c) continue;
                    if (!possible[s][c][v] and !possible[c][f][v])
                        bad = 1;
                }
                total -= bad;
            }
        }
    }

    cout << total << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 0 ms 348 KB Output is correct
10 Correct 1 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 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 1 ms 348 KB Output is correct
23 Correct 0 ms 348 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 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 388 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 0 ms 348 KB Output is correct
10 Correct 1 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 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 1 ms 348 KB Output is correct
23 Correct 0 ms 348 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 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 388 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 6 ms 604 KB Output is correct
37 Correct 6 ms 760 KB Output is correct
38 Correct 19 ms 768 KB Output is correct
39 Correct 29 ms 860 KB Output is correct
40 Correct 36 ms 708 KB Output is correct
41 Correct 5 ms 604 KB Output is correct
42 Correct 5 ms 604 KB Output is correct
43 Correct 6 ms 604 KB Output is correct
44 Correct 5 ms 608 KB Output is correct
45 Correct 5 ms 656 KB Output is correct
46 Correct 5 ms 652 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 6 ms 636 KB Output is correct
49 Correct 5 ms 664 KB Output is correct
50 Correct 5 ms 652 KB Output is correct
51 Correct 23 ms 764 KB Output is correct
52 Correct 25 ms 860 KB Output is correct
53 Correct 28 ms 860 KB Output is correct
54 Correct 27 ms 856 KB Output is correct
55 Correct 27 ms 860 KB Output is correct
56 Correct 28 ms 792 KB Output is correct
57 Correct 24 ms 852 KB Output is correct
58 Correct 27 ms 860 KB Output is correct
59 Correct 19 ms 860 KB Output is correct
60 Correct 14 ms 776 KB Output is correct
61 Correct 11 ms 848 KB Output is correct
62 Correct 7 ms 604 KB Output is correct
63 Correct 21 ms 836 KB Output is correct
64 Correct 24 ms 860 KB Output is correct
65 Correct 24 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 0 ms 348 KB Output is correct
10 Correct 1 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 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 1 ms 348 KB Output is correct
23 Correct 0 ms 348 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 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 388 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 6 ms 604 KB Output is correct
37 Correct 6 ms 760 KB Output is correct
38 Correct 19 ms 768 KB Output is correct
39 Correct 29 ms 860 KB Output is correct
40 Correct 36 ms 708 KB Output is correct
41 Correct 5 ms 604 KB Output is correct
42 Correct 5 ms 604 KB Output is correct
43 Correct 6 ms 604 KB Output is correct
44 Correct 5 ms 608 KB Output is correct
45 Correct 5 ms 656 KB Output is correct
46 Correct 5 ms 652 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 6 ms 636 KB Output is correct
49 Correct 5 ms 664 KB Output is correct
50 Correct 5 ms 652 KB Output is correct
51 Correct 23 ms 764 KB Output is correct
52 Correct 25 ms 860 KB Output is correct
53 Correct 28 ms 860 KB Output is correct
54 Correct 27 ms 856 KB Output is correct
55 Correct 27 ms 860 KB Output is correct
56 Correct 28 ms 792 KB Output is correct
57 Correct 24 ms 852 KB Output is correct
58 Correct 27 ms 860 KB Output is correct
59 Correct 19 ms 860 KB Output is correct
60 Correct 14 ms 776 KB Output is correct
61 Correct 11 ms 848 KB Output is correct
62 Correct 7 ms 604 KB Output is correct
63 Correct 21 ms 836 KB Output is correct
64 Correct 24 ms 860 KB Output is correct
65 Correct 24 ms 860 KB Output is correct
66 Execution timed out 1049 ms 1476 KB Time limit exceeded
67 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 0 ms 348 KB Output is correct
10 Correct 1 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 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 1 ms 348 KB Output is correct
23 Correct 0 ms 348 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 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 388 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 6 ms 604 KB Output is correct
37 Correct 6 ms 760 KB Output is correct
38 Correct 19 ms 768 KB Output is correct
39 Correct 29 ms 860 KB Output is correct
40 Correct 36 ms 708 KB Output is correct
41 Correct 5 ms 604 KB Output is correct
42 Correct 5 ms 604 KB Output is correct
43 Correct 6 ms 604 KB Output is correct
44 Correct 5 ms 608 KB Output is correct
45 Correct 5 ms 656 KB Output is correct
46 Correct 5 ms 652 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 6 ms 636 KB Output is correct
49 Correct 5 ms 664 KB Output is correct
50 Correct 5 ms 652 KB Output is correct
51 Correct 23 ms 764 KB Output is correct
52 Correct 25 ms 860 KB Output is correct
53 Correct 28 ms 860 KB Output is correct
54 Correct 27 ms 856 KB Output is correct
55 Correct 27 ms 860 KB Output is correct
56 Correct 28 ms 792 KB Output is correct
57 Correct 24 ms 852 KB Output is correct
58 Correct 27 ms 860 KB Output is correct
59 Correct 19 ms 860 KB Output is correct
60 Correct 14 ms 776 KB Output is correct
61 Correct 11 ms 848 KB Output is correct
62 Correct 7 ms 604 KB Output is correct
63 Correct 21 ms 836 KB Output is correct
64 Correct 24 ms 860 KB Output is correct
65 Correct 24 ms 860 KB Output is correct
66 Runtime error 1 ms 348 KB Execution killed with signal 11
67 Halted 0 ms 0 KB -