# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
490686 |
2021-11-28T16:45:18 Z |
naal |
Mag (COCI16_mag) |
C++14 |
|
857 ms |
161220 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e6 + 2;
int n, w[N], f[N], res;
vector <int> a[N];
priority_queue <int> q;
void dfs(int u, int par) {
if (w[u] == 1)
f[u] = 1;
while (q.size()) q.pop();
for (int v : a[u])
if (v != par) {
dfs(v, u);
if (w[u] == 1 && w[v] == 1) {
f[u] = max(f[u], f[v] + 1);
q.push(f[v] + 1);
}
}
if (q.size() > 1) {
int tmp = q.top();
q.pop();
tmp += q.top();
q.pop();
res = max(res, tmp - 1);
}
res = max(res, f[u]);
}
signed main() {
cin >> n;
for (int i = 1; i < n; i++) {
int u, v; cin >> u >> v;
a[u].push_back(v);
a[v].push_back(u);
}
res = 1e9;
for (int i = 1; i <= n; i++) {
cin >> w[i];
res = min(res, w[i]);
}
if (res > 1)
cout << res << "/1";
else {
res = 1;
dfs(1, 1);
cout << "1/" << res;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
23756 KB |
Output is correct |
2 |
Incorrect |
13 ms |
23792 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
23756 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
715 ms |
99040 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
23756 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
857 ms |
161220 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
764 ms |
70428 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
789 ms |
72928 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
131 ms |
28968 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
749 ms |
68360 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
786 ms |
71444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |