Submission #511468

# Submission time Handle Problem Language Result Execution time Memory
511468 2022-01-15T22:56:45 Z couplefire Designated Cities (JOI19_designated_cities) C++17
7 / 100
225 ms 29924 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

const int N = 200005;

int n, q; ll ans[N];
vector<array<int, 3>> adj[N];

namespace Task1{
    ll sum = 0, cur = 0;

    void dfs1(int v, int p){
        for(auto [u, d1, d2] : adj[v]){
            sum += d2;
            if(u==p) continue;
            cur += d2; 
            dfs1(u, v);
        }
    }

    void dfs2(int v, int p){
        ans[1] = min(ans[1], sum-cur);
        for(auto [u, d1, d2] : adj[v]){
            if(u==p) continue;
            cur -= d2; cur += d1;
            dfs2(u, v);
            cur += d2; cur -= d1;
        }
    }

    void solve(){
        dfs1(0, 0);
        dfs2(0, 0);
    }
}

namespace Task2{
    void solve(){

    }
}

namespace Task3{
    void solve(){

    }
}

int main(){
    // freopen("a.in", "r", stdin);
    cin.tie(0)->sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i<n-1; ++i){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        --a; --b;
        adj[a].push_back({b, c, d});
        adj[b].push_back({a, d, c});
    }
    memset(ans, 63, sizeof ans);
    Task1::solve();
    Task2::solve();
    Task3::solve();
    cin >> q;
    while(q--){
        int x; cin >> x;
        cout << ans[x] << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 6468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6536 KB Output is correct
2 Correct 185 ms 21144 KB Output is correct
3 Correct 225 ms 29368 KB Output is correct
4 Correct 169 ms 19804 KB Output is correct
5 Correct 171 ms 21044 KB Output is correct
6 Correct 173 ms 22576 KB Output is correct
7 Correct 149 ms 21112 KB Output is correct
8 Correct 205 ms 29924 KB Output is correct
9 Correct 130 ms 21632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 6532 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 6468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6536 KB Output is correct
2 Correct 185 ms 21144 KB Output is correct
3 Correct 225 ms 29368 KB Output is correct
4 Correct 169 ms 19804 KB Output is correct
5 Correct 171 ms 21044 KB Output is correct
6 Correct 173 ms 22576 KB Output is correct
7 Correct 149 ms 21112 KB Output is correct
8 Correct 205 ms 29924 KB Output is correct
9 Correct 130 ms 21632 KB Output is correct
10 Incorrect 5 ms 6532 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 6468 KB Output isn't correct
2 Halted 0 ms 0 KB -