結果
問題 | No.2618 除霊 |
ユーザー | Carpenters-Cat |
提出日時 | 2024-01-27 03:09:45 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 958 bytes |
コンパイル時間 | 2,470 ms |
コンパイル使用メモリ | 205,360 KB |
実行使用メモリ | 25,400 KB |
最終ジャッジ日時 | 2024-01-27 03:09:57 |
合計ジャッジ時間 | 11,899 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
25,400 KB |
testcase_01 | AC | 5 ms
8,092 KB |
testcase_02 | AC | 5 ms
8,092 KB |
testcase_03 | AC | 5 ms
8,092 KB |
testcase_04 | AC | 5 ms
8,092 KB |
testcase_05 | AC | 5 ms
8,092 KB |
testcase_06 | AC | 504 ms
16,540 KB |
testcase_07 | AC | 523 ms
16,540 KB |
testcase_08 | AC | 546 ms
16,668 KB |
testcase_09 | AC | 578 ms
16,540 KB |
testcase_10 | AC | 577 ms
16,668 KB |
testcase_11 | AC | 484 ms
16,696 KB |
testcase_12 | AC | 543 ms
16,540 KB |
testcase_13 | TLE | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; int main () { int N; cin >> N; std::vector<int> tr[200020] ; for (int i = 1; i < N; i ++) { int a, b; cin >> a >> b; tr[--a].push_back(--b); tr[b].push_back(a); } vector<int> ex(N, 0); vector<int> ne_h(N, 0); int M; cin >> M; for (int i = 0; i < M; i ++) { int a; cin >> a; ex[--a] = 1; for (auto v : tr[a]) { ne_h[v] = 1; } ne_h[a] = 1; } int sssu = accumulate(ne_h.begin(), ne_h.end(), 0); vector<int> ans(N, sssu); for (int i = 0; i < N; i ++) { if (!ne_h[i]) continue; ans[i] --; int fl = -1; for (auto v : tr[i]) { if (ex[v]) { if (fl != -1) { fl = -2; } else { fl = v; } } } if (fl >= 0) { ans[fl] --; if (!ex[i]) { for (auto v : tr[fl]) { if (v != i) { ans[v] --; } } } } else if (fl == -1) { for (auto v : tr[i]) { ans[v] --; } } } for (auto a : ans) { cout << a << endl; } }