# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
702675 | 2023-02-24T18:32:41 Z | jhnah917 | Designated Cities (JOI19_designated_cities) | C++14 | 213 ms | 33976 KB |
#include <bits/stdc++.h> using namespace std; using ll = long long; int N, Q; vector<pair<ll,ll>> G[202020]; ll Sum, C[202020], C1; void TreeDP(int v, int b=-1, ll up=0, ll dw=0){ for(auto [i,w] : G[v]) if(i == b) C1 += w, up += w; C[v] = dw - up; for(auto [i,w] : G[v]) if(i != b) TreeDP(i, v, up, dw+w); } int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> N; for(int i=1; i<N; i++){ int a, b, c, d; cin >> a >> b >> c >> d; Sum += c + d; G[a].emplace_back(b, c); G[b].emplace_back(a, d); } cin >> Q; assert(Q == 1); TreeDP(1); for(int q=1; q<=Q; q++){ int t; cin >> t; assert(t == 1); cout << Sum - (C1 + *max_element(C+1, C+N+1)) << "\n"; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 7 ms | 10068 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 5080 KB | Output is correct |
2 | Correct | 179 ms | 23124 KB | Output is correct |
3 | Correct | 187 ms | 33500 KB | Output is correct |
4 | Correct | 201 ms | 21772 KB | Output is correct |
5 | Correct | 160 ms | 23124 KB | Output is correct |
6 | Correct | 168 ms | 24784 KB | Output is correct |
7 | Correct | 139 ms | 22624 KB | Output is correct |
8 | Correct | 213 ms | 33976 KB | Output is correct |
9 | Correct | 119 ms | 22496 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 6 ms | 10068 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 7 ms | 10068 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 5080 KB | Output is correct |
2 | Correct | 179 ms | 23124 KB | Output is correct |
3 | Correct | 187 ms | 33500 KB | Output is correct |
4 | Correct | 201 ms | 21772 KB | Output is correct |
5 | Correct | 160 ms | 23124 KB | Output is correct |
6 | Correct | 168 ms | 24784 KB | Output is correct |
7 | Correct | 139 ms | 22624 KB | Output is correct |
8 | Correct | 213 ms | 33976 KB | Output is correct |
9 | Correct | 119 ms | 22496 KB | Output is correct |
10 | Runtime error | 6 ms | 10068 KB | Execution killed with signal 6 |
11 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 7 ms | 10068 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |