# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
273613 | 2020-08-19T06:08:07 Z | 반딧불(#5107) | Mountains and Valleys (CCO20_day1problem3) | C++17 | 19 ms | 14592 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, m; vector<int> link[500002]; int depth[500002]; void dfs(int x, int par = -1){ for(auto &y: link[x]){ if(y != par){ depth[y] = depth[x] + 1; dfs(y, x); } } } int main(){ scanf("%d %d", &n, &m); for(int i=1; i<=m; i++){ int x, y, w; scanf("%d %d %d", &x, &y, &w); if(w==1) link[x].push_back(y), link[y].push_back(x); } dfs(1); int x = max_element(depth+1, depth+n+1) - depth; memset(depth, 0, sizeof(depth)); dfs(x); printf("%d", 2*n-2-*max_element(depth+1, depth+n+1)); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 13952 KB | Output is correct |
2 | Correct | 10 ms | 13952 KB | Output is correct |
3 | Correct | 13 ms | 14080 KB | Output is correct |
4 | Correct | 10 ms | 13952 KB | Output is correct |
5 | Correct | 12 ms | 13952 KB | Output is correct |
6 | Correct | 10 ms | 13952 KB | Output is correct |
7 | Correct | 10 ms | 13952 KB | Output is correct |
8 | Incorrect | 11 ms | 13952 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 13952 KB | Output is correct |
2 | Correct | 10 ms | 13952 KB | Output is correct |
3 | Correct | 13 ms | 14080 KB | Output is correct |
4 | Correct | 10 ms | 13952 KB | Output is correct |
5 | Correct | 12 ms | 13952 KB | Output is correct |
6 | Correct | 10 ms | 13952 KB | Output is correct |
7 | Correct | 10 ms | 13952 KB | Output is correct |
8 | Incorrect | 11 ms | 13952 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 14592 KB | Output is correct |
2 | Correct | 15 ms | 14336 KB | Output is correct |
3 | Correct | 19 ms | 14336 KB | Output is correct |
4 | Correct | 14 ms | 14336 KB | Output is correct |
5 | Correct | 14 ms | 14208 KB | Output is correct |
6 | Correct | 13 ms | 14208 KB | Output is correct |
7 | Correct | 14 ms | 14336 KB | Output is correct |
8 | Correct | 14 ms | 14336 KB | Output is correct |
9 | Correct | 19 ms | 14368 KB | Output is correct |
10 | Correct | 14 ms | 14208 KB | Output is correct |
11 | Correct | 16 ms | 14336 KB | Output is correct |
12 | Correct | 14 ms | 14336 KB | Output is correct |
13 | Correct | 14 ms | 14336 KB | Output is correct |
14 | Correct | 14 ms | 14336 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 13952 KB | Output is correct |
2 | Correct | 10 ms | 13952 KB | Output is correct |
3 | Correct | 13 ms | 14080 KB | Output is correct |
4 | Correct | 10 ms | 13952 KB | Output is correct |
5 | Correct | 12 ms | 13952 KB | Output is correct |
6 | Correct | 10 ms | 13952 KB | Output is correct |
7 | Correct | 10 ms | 13952 KB | Output is correct |
8 | Incorrect | 11 ms | 13952 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 13952 KB | Output is correct |
2 | Correct | 10 ms | 13952 KB | Output is correct |
3 | Correct | 13 ms | 14080 KB | Output is correct |
4 | Correct | 10 ms | 13952 KB | Output is correct |
5 | Correct | 12 ms | 13952 KB | Output is correct |
6 | Correct | 10 ms | 13952 KB | Output is correct |
7 | Correct | 10 ms | 13952 KB | Output is correct |
8 | Incorrect | 11 ms | 13952 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 13952 KB | Output is correct |
2 | Correct | 10 ms | 13952 KB | Output is correct |
3 | Correct | 13 ms | 14080 KB | Output is correct |
4 | Correct | 10 ms | 13952 KB | Output is correct |
5 | Correct | 12 ms | 13952 KB | Output is correct |
6 | Correct | 10 ms | 13952 KB | Output is correct |
7 | Correct | 10 ms | 13952 KB | Output is correct |
8 | Incorrect | 11 ms | 13952 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 13952 KB | Output is correct |
2 | Correct | 10 ms | 13952 KB | Output is correct |
3 | Correct | 13 ms | 14080 KB | Output is correct |
4 | Correct | 10 ms | 13952 KB | Output is correct |
5 | Correct | 12 ms | 13952 KB | Output is correct |
6 | Correct | 10 ms | 13952 KB | Output is correct |
7 | Correct | 10 ms | 13952 KB | Output is correct |
8 | Incorrect | 11 ms | 13952 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 13952 KB | Output is correct |
2 | Correct | 10 ms | 13952 KB | Output is correct |
3 | Correct | 13 ms | 14080 KB | Output is correct |
4 | Correct | 10 ms | 13952 KB | Output is correct |
5 | Correct | 12 ms | 13952 KB | Output is correct |
6 | Correct | 10 ms | 13952 KB | Output is correct |
7 | Correct | 10 ms | 13952 KB | Output is correct |
8 | Incorrect | 11 ms | 13952 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |