# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
273466 | 2020-08-19T05:28:51 Z | 반딧불(#5107) | Mountains and Valleys (CCO20_day1problem3) | C++17 | 15 ms | 14688 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-*max_element(depth+1, depth+n+1)); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 12 ms | 13952 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 12 ms | 13952 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 15 ms | 14688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 12 ms | 13952 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 12 ms | 13952 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 12 ms | 13952 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 12 ms | 13952 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 12 ms | 13952 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |