# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
127119 | 2019-07-08T23:45:36 Z | wilwxk | Designated Cities (JOI19_designated_cities) | C++14 | 423 ms | 39496 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN=2e5+5; vector<tuple<int, ll, ll> > g[MAXN]; ll dp[MAXN]; ll respf[MAXN], somaf; int n, q; void predfs(int cur, int p) { for(auto aresta : g[cur]) { int viz; ll peso, rpeso; tie(viz, peso, rpeso)=aresta; if(viz==p) continue; predfs(viz, cur); dp[cur]+=dp[viz]+rpeso; } } void dfs(int cur, int p) { respf[1]=max(respf[1], dp[cur]); // printf("dp[%d]= %lld\n", cur, dp[cur]); for(auto aresta : g[cur]) { int viz; ll peso, rpeso; tie(viz, peso, rpeso)=aresta; if(viz==p) continue; ll dpc=dp[cur], dpv=dp[viz]; dp[cur]-=(dp[viz]+rpeso); dp[viz]+=(dp[cur]+peso); dfs(viz, cur); dp[cur]=dpc; dp[viz]=dpv; } } int main() { scanf("%d", &n); for(int i=1; i<n; i++) { int a, b, c, d; scanf("%d %d %d %d", &a, &b, &c, &d); g[a].push_back({b, c, d}); g[b].push_back({a, d, c}); somaf+=c; somaf+=d; } predfs(1, 1); dfs(1, 1); scanf("%d", &q); while(q--) { int val; scanf("%d", &val); printf("%lld\n", somaf-respf[val]); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 4984 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 4984 KB | Output is correct |
2 | Correct | 290 ms | 26148 KB | Output is correct |
3 | Correct | 336 ms | 38904 KB | Output is correct |
4 | Correct | 248 ms | 24668 KB | Output is correct |
5 | Correct | 272 ms | 25900 KB | Output is correct |
6 | Correct | 337 ms | 28024 KB | Output is correct |
7 | Correct | 252 ms | 24996 KB | Output is correct |
8 | Correct | 423 ms | 39496 KB | Output is correct |
9 | Correct | 272 ms | 24092 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 4984 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 4984 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 4984 KB | Output is correct |
2 | Correct | 290 ms | 26148 KB | Output is correct |
3 | Correct | 336 ms | 38904 KB | Output is correct |
4 | Correct | 248 ms | 24668 KB | Output is correct |
5 | Correct | 272 ms | 25900 KB | Output is correct |
6 | Correct | 337 ms | 28024 KB | Output is correct |
7 | Correct | 252 ms | 24996 KB | Output is correct |
8 | Correct | 423 ms | 39496 KB | Output is correct |
9 | Correct | 272 ms | 24092 KB | Output is correct |
10 | Incorrect | 7 ms | 4984 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 4984 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |