結果
問題 | No.2325 Skill Tree |
ユーザー | Ryoga.exe |
提出日時 | 2023-05-28 15:09:32 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,182 bytes |
コンパイル時間 | 2,269 ms |
コンパイル使用メモリ | 210,280 KB |
実行使用メモリ | 14,344 KB |
最終ジャッジ日時 | 2023-08-27 11:32:30 |
合計ジャッジ時間 | 21,504 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | WA | - |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 2 ms
4,380 KB |
testcase_07 | AC | 255 ms
4,684 KB |
testcase_08 | AC | 175 ms
7,524 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 300 ms
8,704 KB |
testcase_12 | AC | 551 ms
14,124 KB |
testcase_13 | AC | 537 ms
13,976 KB |
testcase_14 | AC | 542 ms
14,048 KB |
testcase_15 | WA | - |
testcase_16 | AC | 540 ms
14,064 KB |
testcase_17 | AC | 538 ms
14,060 KB |
testcase_18 | AC | 528 ms
14,068 KB |
testcase_19 | AC | 529 ms
14,056 KB |
testcase_20 | WA | - |
testcase_21 | AC | 530 ms
14,052 KB |
testcase_22 | AC | 549 ms
14,040 KB |
testcase_23 | WA | - |
testcase_24 | AC | 549 ms
14,056 KB |
testcase_25 | AC | 546 ms
14,192 KB |
testcase_26 | AC | 549 ms
13,980 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int n; cin >> n; vector<vector<int>> g(n); vector<int> levels(n); for (int i = 1; i < n; i++) { int l, a; cin >> l >> a; --a; levels[i] = l; g[a].push_back(i); } vector<int> type2(n, -1); queue<int> que; que.push(0); type2[0] = 0; while (!que.empty()) { auto cur = que.front(); que.pop(); for (auto to : g[cur]) { if (auto greaterLevel = max(levels[to], levels[cur]); type2[to] < greaterLevel) { type2[to] = greaterLevel; } que.push(to); } } auto type1 = type2; int exclude = 0; for (int i = 0; i < n; i++) { if (type1[i] == -1) { exclude++; } } sort(type1.begin(), type1.end()); int q; cin >> q; while (q--) { int type, x; cin >> type >> x; if (type == 1) { cout << (upper_bound(type1.begin(), type1.end(), x) - type1.begin()) - exclude << endl; } else { cout << type2[x - 1] << endl; } } }