# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
105256 | 2019-04-11T04:34:37 Z | antimirage | Designated Cities (JOI19_designated_cities) | C++14 | 360 ms | 32640 KB |
#include <bits/stdc++.h> #define fr first #define sc second #define mk make_pair #define pb push_back #define all(s) s.begin(), s.end() using namespace std; const int N = 2e5 + 5; int n, q, x, y, c, d; long long ans, pref[N], ALL, res; vector < vector < pair <int, pair <int, int> > > > g; void dfs (int v, int p = 0) { for (auto to : g[v]){ if (to.fr == p) continue; pref[to.fr] = pref[v] + to.sc.fr - to.sc.sc; dfs(to.fr, v); ans += to.sc.sc; ALL += to.sc.fr; ALL += to.sc.sc; } } main(){ cin >> n; g.resize(n + 1); for (int i = 1; i < n; i++){ scanf("%d%d%d%d", &x, &y, &c, &d); g[x].pb( mk( y, mk(c, d) ) ); g[y].pb( mk( x, mk(d, c) ) ); } dfs(1); for (int i = 1; i <= n; i++){ res = max(res, ans + pref[i]); } cin >> q; while (q--){ cin >> x; cout << ALL - res << endl; } } /** 4 1 2 1 2 1 3 3 4 1 4 5 6 **/
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 356 KB | Output is correct |
2 | Correct | 334 ms | 16652 KB | Output is correct |
3 | Correct | 326 ms | 32068 KB | Output is correct |
4 | Correct | 271 ms | 19832 KB | Output is correct |
5 | Correct | 280 ms | 20996 KB | Output is correct |
6 | Correct | 295 ms | 22876 KB | Output is correct |
7 | Correct | 256 ms | 21048 KB | Output is correct |
8 | Correct | 360 ms | 32640 KB | Output is correct |
9 | Correct | 249 ms | 21696 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 256 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 356 KB | Output is correct |
2 | Correct | 334 ms | 16652 KB | Output is correct |
3 | Correct | 326 ms | 32068 KB | Output is correct |
4 | Correct | 271 ms | 19832 KB | Output is correct |
5 | Correct | 280 ms | 20996 KB | Output is correct |
6 | Correct | 295 ms | 22876 KB | Output is correct |
7 | Correct | 256 ms | 21048 KB | Output is correct |
8 | Correct | 360 ms | 32640 KB | Output is correct |
9 | Correct | 249 ms | 21696 KB | Output is correct |
10 | Incorrect | 2 ms | 256 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |