Submission #490684

# Submission time Handle Problem Language Result Execution time Memory
490684 2021-11-28T16:40:12 Z naal Mag (COCI16_mag) C++14
12 / 120
883 ms 147520 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];

void dfs(int u, int par) {
    if (w[u] == 1)
        f[u] = 1;
    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);
        }
    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 13 ms 23832 KB Output is correct
2 Correct 13 ms 23784 KB Output is 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 681 ms 100248 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 23756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 883 ms 147520 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 774 ms 85744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 828 ms 90124 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 108 ms 30364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 776 ms 83544 KB Output is correct
2 Incorrect 882 ms 87172 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 800 ms 86556 KB Output is correct
2 Incorrect 521 ms 57852 KB Output isn't correct