# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
696408 | 2023-02-06T12:27:00 Z | Quan2003 | Duathlon (APIO18_duathlon) | C++17 | 96 ms | 41164 KB |
#include<bits/stdc++.h> #include<iostream> using namespace std; typedef long long ll; typedef long double ld; const int N = 5e5 + 5; int up[21][N + 1]; int dp[N + 1]; int a[N + 1]; int n,m,q; long long res; vector<int>adj[N + 1]; vector<int>tadj[N + 1]; int trs,dsz,psz; bool vis[N + 1]; int st[N + 1],low[N + 1]; int comsize = 0; void dfs(int u,int p){ a[u] = low[u] = ++dsz; st[++psz] = u; comsize++; for(int i = 0; i < tadj[u].size(); i++){ int v = tadj[u][i]; if(v == p) continue; if(!a[v]){ dfs(v,u); low[u] = min(low[u] , low[v]); if( low[v] >= a[u]){ int j = u; trs++; adj[u].push_back(trs); // adj[trs].push_back(u); while(j != v){ j = st[psz--]; adj[trs].push_back(j); // adj[j].push_back(trs); } } } else low[u] = min(a[v] , low[u]); } } void dfs_calc(int u){ dp[u] = (u <= n); for(int i = 0; i < adj[u].size(); i++){ int v = adj[u][i]; dfs_calc(v); dp[u] += dp[v]; if(u > n) res = res - (long long) adj[u].size() * (dp[v] - 1) * dp[v]; } if(u > n) res = res - (long long) adj[u].size() * (comsize - dp[u] - 1) * (comsize - dp[u]); } int main(){ scanf("%d%d",&n,&m); for(int i = 0; i < m; i++){ int u,v; scanf("%d%d",&u,&v); tadj[u].push_back(v); tadj[v].push_back(u); } trs = n; for(int i = 1; i <= n; i++){ if(!a[i]){ comsize = 0; dfs(i,0); res += comsize * (comsize - 1) * (comsize - 2); dfs_calc(i); } } cout<<res<<endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 23888 KB | Output is correct |
2 | Correct | 13 ms | 23800 KB | Output is correct |
3 | Correct | 11 ms | 23800 KB | Output is correct |
4 | Correct | 15 ms | 23724 KB | Output is correct |
5 | Correct | 12 ms | 23724 KB | Output is correct |
6 | Correct | 12 ms | 23768 KB | Output is correct |
7 | Correct | 12 ms | 23764 KB | Output is correct |
8 | Correct | 11 ms | 23764 KB | Output is correct |
9 | Correct | 13 ms | 23764 KB | Output is correct |
10 | Correct | 12 ms | 23740 KB | Output is correct |
11 | Correct | 11 ms | 23796 KB | Output is correct |
12 | Correct | 14 ms | 23796 KB | Output is correct |
13 | Correct | 14 ms | 23768 KB | Output is correct |
14 | Correct | 15 ms | 23784 KB | Output is correct |
15 | Correct | 15 ms | 23764 KB | Output is correct |
16 | Correct | 12 ms | 23764 KB | Output is correct |
17 | Correct | 14 ms | 23796 KB | Output is correct |
18 | Correct | 11 ms | 23788 KB | Output is correct |
19 | Correct | 12 ms | 23764 KB | Output is correct |
20 | Correct | 12 ms | 23764 KB | Output is correct |
21 | Correct | 12 ms | 23724 KB | Output is correct |
22 | Correct | 12 ms | 23800 KB | Output is correct |
23 | Correct | 11 ms | 23764 KB | Output is correct |
24 | Correct | 11 ms | 23748 KB | Output is correct |
25 | Correct | 15 ms | 23760 KB | Output is correct |
26 | Correct | 12 ms | 23764 KB | Output is correct |
27 | Correct | 12 ms | 23812 KB | Output is correct |
28 | Correct | 12 ms | 23764 KB | Output is correct |
29 | Correct | 14 ms | 23796 KB | Output is correct |
30 | Correct | 14 ms | 23796 KB | Output is correct |
31 | Correct | 15 ms | 23800 KB | Output is correct |
32 | Correct | 16 ms | 23712 KB | Output is correct |
33 | Correct | 13 ms | 23792 KB | Output is correct |
34 | Correct | 11 ms | 23764 KB | Output is correct |
35 | Correct | 12 ms | 23752 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 23888 KB | Output is correct |
2 | Correct | 13 ms | 23800 KB | Output is correct |
3 | Correct | 11 ms | 23800 KB | Output is correct |
4 | Correct | 15 ms | 23724 KB | Output is correct |
5 | Correct | 12 ms | 23724 KB | Output is correct |
6 | Correct | 12 ms | 23768 KB | Output is correct |
7 | Correct | 12 ms | 23764 KB | Output is correct |
8 | Correct | 11 ms | 23764 KB | Output is correct |
9 | Correct | 13 ms | 23764 KB | Output is correct |
10 | Correct | 12 ms | 23740 KB | Output is correct |
11 | Correct | 11 ms | 23796 KB | Output is correct |
12 | Correct | 14 ms | 23796 KB | Output is correct |
13 | Correct | 14 ms | 23768 KB | Output is correct |
14 | Correct | 15 ms | 23784 KB | Output is correct |
15 | Correct | 15 ms | 23764 KB | Output is correct |
16 | Correct | 12 ms | 23764 KB | Output is correct |
17 | Correct | 14 ms | 23796 KB | Output is correct |
18 | Correct | 11 ms | 23788 KB | Output is correct |
19 | Correct | 12 ms | 23764 KB | Output is correct |
20 | Correct | 12 ms | 23764 KB | Output is correct |
21 | Correct | 12 ms | 23724 KB | Output is correct |
22 | Correct | 12 ms | 23800 KB | Output is correct |
23 | Correct | 11 ms | 23764 KB | Output is correct |
24 | Correct | 11 ms | 23748 KB | Output is correct |
25 | Correct | 15 ms | 23760 KB | Output is correct |
26 | Correct | 12 ms | 23764 KB | Output is correct |
27 | Correct | 12 ms | 23812 KB | Output is correct |
28 | Correct | 12 ms | 23764 KB | Output is correct |
29 | Correct | 14 ms | 23796 KB | Output is correct |
30 | Correct | 14 ms | 23796 KB | Output is correct |
31 | Correct | 15 ms | 23800 KB | Output is correct |
32 | Correct | 16 ms | 23712 KB | Output is correct |
33 | Correct | 13 ms | 23792 KB | Output is correct |
34 | Correct | 11 ms | 23764 KB | Output is correct |
35 | Correct | 12 ms | 23752 KB | Output is correct |
36 | Correct | 13 ms | 23776 KB | Output is correct |
37 | Correct | 12 ms | 23792 KB | Output is correct |
38 | Correct | 14 ms | 23728 KB | Output is correct |
39 | Correct | 14 ms | 23892 KB | Output is correct |
40 | Correct | 13 ms | 23784 KB | Output is correct |
41 | Correct | 15 ms | 23792 KB | Output is correct |
42 | Correct | 14 ms | 23812 KB | Output is correct |
43 | Correct | 15 ms | 23728 KB | Output is correct |
44 | Correct | 13 ms | 23800 KB | Output is correct |
45 | Correct | 14 ms | 23804 KB | Output is correct |
46 | Correct | 16 ms | 23732 KB | Output is correct |
47 | Correct | 11 ms | 23764 KB | Output is correct |
48 | Correct | 11 ms | 23764 KB | Output is correct |
49 | Correct | 12 ms | 23796 KB | Output is correct |
50 | Correct | 15 ms | 23744 KB | Output is correct |
51 | Correct | 13 ms | 23824 KB | Output is correct |
52 | Correct | 13 ms | 23752 KB | Output is correct |
53 | Correct | 15 ms | 23796 KB | Output is correct |
54 | Correct | 12 ms | 23772 KB | Output is correct |
55 | Correct | 14 ms | 23780 KB | Output is correct |
56 | Correct | 13 ms | 23796 KB | Output is correct |
57 | Correct | 11 ms | 23764 KB | Output is correct |
58 | Correct | 12 ms | 23800 KB | Output is correct |
59 | Correct | 12 ms | 23792 KB | Output is correct |
60 | Correct | 12 ms | 23764 KB | Output is correct |
61 | Correct | 12 ms | 23792 KB | Output is correct |
62 | Correct | 11 ms | 23720 KB | Output is correct |
63 | Correct | 12 ms | 23708 KB | Output is correct |
64 | Correct | 13 ms | 23792 KB | Output is correct |
65 | Correct | 11 ms | 23792 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 95 ms | 41164 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 23856 KB | Output is correct |
2 | Correct | 13 ms | 23808 KB | Output is correct |
3 | Correct | 13 ms | 23908 KB | Output is correct |
4 | Correct | 13 ms | 23936 KB | Output is correct |
5 | Correct | 13 ms | 23892 KB | Output is correct |
6 | Correct | 13 ms | 23932 KB | Output is correct |
7 | Correct | 14 ms | 23892 KB | Output is correct |
8 | Correct | 12 ms | 23892 KB | Output is correct |
9 | Correct | 13 ms | 23928 KB | Output is correct |
10 | Correct | 12 ms | 23824 KB | Output is correct |
11 | Correct | 12 ms | 23812 KB | Output is correct |
12 | Correct | 15 ms | 23892 KB | Output is correct |
13 | Correct | 15 ms | 23888 KB | Output is correct |
14 | Correct | 12 ms | 23860 KB | Output is correct |
15 | Correct | 12 ms | 23804 KB | Output is correct |
16 | Correct | 12 ms | 23892 KB | Output is correct |
17 | Correct | 15 ms | 23904 KB | Output is correct |
18 | Correct | 13 ms | 23812 KB | Output is correct |
19 | Correct | 12 ms | 23892 KB | Output is correct |
20 | Correct | 13 ms | 23808 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 83 ms | 34492 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 23804 KB | Output is correct |
2 | Correct | 14 ms | 23812 KB | Output is correct |
3 | Correct | 13 ms | 23804 KB | Output is correct |
4 | Correct | 13 ms | 23808 KB | Output is correct |
5 | Correct | 13 ms | 23804 KB | Output is correct |
6 | Correct | 12 ms | 23764 KB | Output is correct |
7 | Correct | 13 ms | 23772 KB | Output is correct |
8 | Correct | 13 ms | 23804 KB | Output is correct |
9 | Correct | 12 ms | 23764 KB | Output is correct |
10 | Correct | 13 ms | 23828 KB | Output is correct |
11 | Correct | 15 ms | 23892 KB | Output is correct |
12 | Correct | 14 ms | 23932 KB | Output is correct |
13 | Correct | 13 ms | 23892 KB | Output is correct |
14 | Correct | 13 ms | 23880 KB | Output is correct |
15 | Correct | 13 ms | 23892 KB | Output is correct |
16 | Correct | 13 ms | 23892 KB | Output is correct |
17 | Correct | 13 ms | 23892 KB | Output is correct |
18 | Correct | 13 ms | 23892 KB | Output is correct |
19 | Correct | 13 ms | 23804 KB | Output is correct |
20 | Correct | 14 ms | 23892 KB | Output is correct |
21 | Correct | 14 ms | 23908 KB | Output is correct |
22 | Correct | 14 ms | 23804 KB | Output is correct |
23 | Correct | 13 ms | 23892 KB | Output is correct |
24 | Correct | 13 ms | 23812 KB | Output is correct |
25 | Correct | 12 ms | 23784 KB | Output is correct |
26 | Correct | 13 ms | 23764 KB | Output is correct |
27 | Correct | 13 ms | 23764 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 96 ms | 34576 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 23888 KB | Output is correct |
2 | Correct | 13 ms | 23800 KB | Output is correct |
3 | Correct | 11 ms | 23800 KB | Output is correct |
4 | Correct | 15 ms | 23724 KB | Output is correct |
5 | Correct | 12 ms | 23724 KB | Output is correct |
6 | Correct | 12 ms | 23768 KB | Output is correct |
7 | Correct | 12 ms | 23764 KB | Output is correct |
8 | Correct | 11 ms | 23764 KB | Output is correct |
9 | Correct | 13 ms | 23764 KB | Output is correct |
10 | Correct | 12 ms | 23740 KB | Output is correct |
11 | Correct | 11 ms | 23796 KB | Output is correct |
12 | Correct | 14 ms | 23796 KB | Output is correct |
13 | Correct | 14 ms | 23768 KB | Output is correct |
14 | Correct | 15 ms | 23784 KB | Output is correct |
15 | Correct | 15 ms | 23764 KB | Output is correct |
16 | Correct | 12 ms | 23764 KB | Output is correct |
17 | Correct | 14 ms | 23796 KB | Output is correct |
18 | Correct | 11 ms | 23788 KB | Output is correct |
19 | Correct | 12 ms | 23764 KB | Output is correct |
20 | Correct | 12 ms | 23764 KB | Output is correct |
21 | Correct | 12 ms | 23724 KB | Output is correct |
22 | Correct | 12 ms | 23800 KB | Output is correct |
23 | Correct | 11 ms | 23764 KB | Output is correct |
24 | Correct | 11 ms | 23748 KB | Output is correct |
25 | Correct | 15 ms | 23760 KB | Output is correct |
26 | Correct | 12 ms | 23764 KB | Output is correct |
27 | Correct | 12 ms | 23812 KB | Output is correct |
28 | Correct | 12 ms | 23764 KB | Output is correct |
29 | Correct | 14 ms | 23796 KB | Output is correct |
30 | Correct | 14 ms | 23796 KB | Output is correct |
31 | Correct | 15 ms | 23800 KB | Output is correct |
32 | Correct | 16 ms | 23712 KB | Output is correct |
33 | Correct | 13 ms | 23792 KB | Output is correct |
34 | Correct | 11 ms | 23764 KB | Output is correct |
35 | Correct | 12 ms | 23752 KB | Output is correct |
36 | Correct | 13 ms | 23776 KB | Output is correct |
37 | Correct | 12 ms | 23792 KB | Output is correct |
38 | Correct | 14 ms | 23728 KB | Output is correct |
39 | Correct | 14 ms | 23892 KB | Output is correct |
40 | Correct | 13 ms | 23784 KB | Output is correct |
41 | Correct | 15 ms | 23792 KB | Output is correct |
42 | Correct | 14 ms | 23812 KB | Output is correct |
43 | Correct | 15 ms | 23728 KB | Output is correct |
44 | Correct | 13 ms | 23800 KB | Output is correct |
45 | Correct | 14 ms | 23804 KB | Output is correct |
46 | Correct | 16 ms | 23732 KB | Output is correct |
47 | Correct | 11 ms | 23764 KB | Output is correct |
48 | Correct | 11 ms | 23764 KB | Output is correct |
49 | Correct | 12 ms | 23796 KB | Output is correct |
50 | Correct | 15 ms | 23744 KB | Output is correct |
51 | Correct | 13 ms | 23824 KB | Output is correct |
52 | Correct | 13 ms | 23752 KB | Output is correct |
53 | Correct | 15 ms | 23796 KB | Output is correct |
54 | Correct | 12 ms | 23772 KB | Output is correct |
55 | Correct | 14 ms | 23780 KB | Output is correct |
56 | Correct | 13 ms | 23796 KB | Output is correct |
57 | Correct | 11 ms | 23764 KB | Output is correct |
58 | Correct | 12 ms | 23800 KB | Output is correct |
59 | Correct | 12 ms | 23792 KB | Output is correct |
60 | Correct | 12 ms | 23764 KB | Output is correct |
61 | Correct | 12 ms | 23792 KB | Output is correct |
62 | Correct | 11 ms | 23720 KB | Output is correct |
63 | Correct | 12 ms | 23708 KB | Output is correct |
64 | Correct | 13 ms | 23792 KB | Output is correct |
65 | Correct | 11 ms | 23792 KB | Output is correct |
66 | Correct | 12 ms | 23764 KB | Output is correct |
67 | Correct | 12 ms | 23804 KB | Output is correct |
68 | Correct | 16 ms | 23892 KB | Output is correct |
69 | Correct | 13 ms | 23944 KB | Output is correct |
70 | Correct | 17 ms | 23892 KB | Output is correct |
71 | Correct | 13 ms | 23796 KB | Output is correct |
72 | Correct | 14 ms | 23892 KB | Output is correct |
73 | Correct | 16 ms | 23808 KB | Output is correct |
74 | Correct | 12 ms | 23892 KB | Output is correct |
75 | Correct | 12 ms | 23840 KB | Output is correct |
76 | Correct | 12 ms | 23764 KB | Output is correct |
77 | Correct | 12 ms | 23880 KB | Output is correct |
78 | Correct | 12 ms | 23892 KB | Output is correct |
79 | Correct | 12 ms | 23856 KB | Output is correct |
80 | Correct | 12 ms | 23768 KB | Output is correct |
81 | Correct | 12 ms | 23808 KB | Output is correct |
82 | Correct | 12 ms | 23892 KB | Output is correct |
83 | Correct | 13 ms | 23932 KB | Output is correct |
84 | Correct | 12 ms | 23892 KB | Output is correct |
85 | Correct | 15 ms | 23892 KB | Output is correct |
86 | Correct | 12 ms | 23804 KB | Output is correct |
87 | Correct | 15 ms | 23856 KB | Output is correct |
88 | Correct | 16 ms | 23876 KB | Output is correct |
89 | Correct | 15 ms | 23812 KB | Output is correct |
90 | Correct | 13 ms | 23816 KB | Output is correct |
91 | Correct | 12 ms | 23812 KB | Output is correct |
92 | Correct | 12 ms | 23784 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 23888 KB | Output is correct |
2 | Correct | 13 ms | 23800 KB | Output is correct |
3 | Correct | 11 ms | 23800 KB | Output is correct |
4 | Correct | 15 ms | 23724 KB | Output is correct |
5 | Correct | 12 ms | 23724 KB | Output is correct |
6 | Correct | 12 ms | 23768 KB | Output is correct |
7 | Correct | 12 ms | 23764 KB | Output is correct |
8 | Correct | 11 ms | 23764 KB | Output is correct |
9 | Correct | 13 ms | 23764 KB | Output is correct |
10 | Correct | 12 ms | 23740 KB | Output is correct |
11 | Correct | 11 ms | 23796 KB | Output is correct |
12 | Correct | 14 ms | 23796 KB | Output is correct |
13 | Correct | 14 ms | 23768 KB | Output is correct |
14 | Correct | 15 ms | 23784 KB | Output is correct |
15 | Correct | 15 ms | 23764 KB | Output is correct |
16 | Correct | 12 ms | 23764 KB | Output is correct |
17 | Correct | 14 ms | 23796 KB | Output is correct |
18 | Correct | 11 ms | 23788 KB | Output is correct |
19 | Correct | 12 ms | 23764 KB | Output is correct |
20 | Correct | 12 ms | 23764 KB | Output is correct |
21 | Correct | 12 ms | 23724 KB | Output is correct |
22 | Correct | 12 ms | 23800 KB | Output is correct |
23 | Correct | 11 ms | 23764 KB | Output is correct |
24 | Correct | 11 ms | 23748 KB | Output is correct |
25 | Correct | 15 ms | 23760 KB | Output is correct |
26 | Correct | 12 ms | 23764 KB | Output is correct |
27 | Correct | 12 ms | 23812 KB | Output is correct |
28 | Correct | 12 ms | 23764 KB | Output is correct |
29 | Correct | 14 ms | 23796 KB | Output is correct |
30 | Correct | 14 ms | 23796 KB | Output is correct |
31 | Correct | 15 ms | 23800 KB | Output is correct |
32 | Correct | 16 ms | 23712 KB | Output is correct |
33 | Correct | 13 ms | 23792 KB | Output is correct |
34 | Correct | 11 ms | 23764 KB | Output is correct |
35 | Correct | 12 ms | 23752 KB | Output is correct |
36 | Correct | 13 ms | 23776 KB | Output is correct |
37 | Correct | 12 ms | 23792 KB | Output is correct |
38 | Correct | 14 ms | 23728 KB | Output is correct |
39 | Correct | 14 ms | 23892 KB | Output is correct |
40 | Correct | 13 ms | 23784 KB | Output is correct |
41 | Correct | 15 ms | 23792 KB | Output is correct |
42 | Correct | 14 ms | 23812 KB | Output is correct |
43 | Correct | 15 ms | 23728 KB | Output is correct |
44 | Correct | 13 ms | 23800 KB | Output is correct |
45 | Correct | 14 ms | 23804 KB | Output is correct |
46 | Correct | 16 ms | 23732 KB | Output is correct |
47 | Correct | 11 ms | 23764 KB | Output is correct |
48 | Correct | 11 ms | 23764 KB | Output is correct |
49 | Correct | 12 ms | 23796 KB | Output is correct |
50 | Correct | 15 ms | 23744 KB | Output is correct |
51 | Correct | 13 ms | 23824 KB | Output is correct |
52 | Correct | 13 ms | 23752 KB | Output is correct |
53 | Correct | 15 ms | 23796 KB | Output is correct |
54 | Correct | 12 ms | 23772 KB | Output is correct |
55 | Correct | 14 ms | 23780 KB | Output is correct |
56 | Correct | 13 ms | 23796 KB | Output is correct |
57 | Correct | 11 ms | 23764 KB | Output is correct |
58 | Correct | 12 ms | 23800 KB | Output is correct |
59 | Correct | 12 ms | 23792 KB | Output is correct |
60 | Correct | 12 ms | 23764 KB | Output is correct |
61 | Correct | 12 ms | 23792 KB | Output is correct |
62 | Correct | 11 ms | 23720 KB | Output is correct |
63 | Correct | 12 ms | 23708 KB | Output is correct |
64 | Correct | 13 ms | 23792 KB | Output is correct |
65 | Correct | 11 ms | 23792 KB | Output is correct |
66 | Incorrect | 95 ms | 41164 KB | Output isn't correct |
67 | Halted | 0 ms | 0 KB | - |