QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#180259 | #2169. 'S No Problem | Alleks_B | WA | 1ms | 6040kb | C++14 | 624b | 2023-09-15 17:21:17 | 2023-09-15 17:21:17 |
Judging History
answer
#include <bits/stdc++.h>
#define L 100005
using namespace std;
int n;
vector <pair <int, int>> G[L];
int root = 1, pathLength, maxPath;
bool vis[L];
void DFS(int node) {
vis[node] = true;
maxPath = max(maxPath, pathLength);
for (auto it : G[node]) {
if (!vis[it.first]) {
pathLength += it.second;
DFS(it.first);
pathLength -= it.second;
}
}
}
int main(){
cin >> n;
for (int i = 1; i < n; i++) {
int a, b, c;
cin >> a >> b >> c;
G[a].push_back({b, c});
G[b].push_back({a, c});
}
DFS(root);
cout << maxPath << "\n";
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 6040kb
input:
5 1 2 1 1 3 2 1 4 3 1 5 4
output:
4
result:
wrong answer 1st lines differ - expected: '10', found: '4'