Submission #953466

# Submission time Handle Problem Language Result Execution time Memory
953466 2024-03-26T02:41:42 Z tnknguyen_ Vinjete (COI22_vinjete) C++14
0 / 100
3 ms 5724 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n' 
#define pii pair<int, int>

const int MX = 1e5 + 5;
vector<pair<int, pii>> gr[MX];
int L[MX], R[MX], f[MX];
int ans[MX];

void dfs(int u, int p){
    ans[u] = (R[u] - L[u] + 1);
    for(pair<int, pii> e : gr[u]){
        int v, l, r;
        v = e.first;
        tie(l, r) = e.second;
        if(v != p){
            L[v] = min({L[v], L[u], l});
            R[v] = max({R[v], R[u], r});
            dfs(v, u);
        }
    }
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

//    freopen("main.inp","r",stdin);
//    freopen("main.out","w",stdout);

    int n, m;
    cin>>n>>m;

    for(int i=1; i<n; ++i){
        int u, v, l, r;
        cin>>u>>v>>l>>r;
        gr[u].push_back({v, {l, r}});
        gr[v].push_back({u, {l, r}});
    }

    memset(L, 63, sizeof L);
    memset(R, -63, sizeof R);
    dfs(1, 0);

    for(int i=2; i<=n; ++i){
        cout<<ans[i]<<endl;
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 5724 KB Output is correct
2 Correct 3 ms 5724 KB Output is correct
3 Incorrect 2 ms 5724 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 5724 KB Output is correct
2 Correct 3 ms 5724 KB Output is correct
3 Incorrect 2 ms 5724 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 5724 KB Output is correct
2 Correct 3 ms 5724 KB Output is correct
3 Incorrect 2 ms 5724 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 5724 KB Output is correct
2 Correct 3 ms 5724 KB Output is correct
3 Incorrect 2 ms 5724 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 5724 KB Output is correct
2 Correct 3 ms 5724 KB Output is correct
3 Incorrect 2 ms 5724 KB Output isn't correct
4 Halted 0 ms 0 KB -