結果
問題 | No.2325 Skill Tree |
ユーザー | mayocorn |
提出日時 | 2023-05-28 13:58:33 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 177 ms / 3,000 ms |
コード長 | 2,944 bytes |
コンパイル時間 | 4,134 ms |
コンパイル使用メモリ | 242,136 KB |
実行使用メモリ | 17,792 KB |
最終ジャッジ日時 | 2024-06-08 04:26:26 |
合計ジャッジ時間 | 11,340 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 1 ms
5,376 KB |
testcase_07 | AC | 37 ms
5,376 KB |
testcase_08 | AC | 40 ms
8,832 KB |
testcase_09 | AC | 49 ms
7,040 KB |
testcase_10 | AC | 60 ms
12,672 KB |
testcase_11 | AC | 60 ms
9,984 KB |
testcase_12 | AC | 119 ms
17,024 KB |
testcase_13 | AC | 120 ms
16,896 KB |
testcase_14 | AC | 120 ms
17,024 KB |
testcase_15 | AC | 114 ms
16,896 KB |
testcase_16 | AC | 117 ms
16,896 KB |
testcase_17 | AC | 113 ms
16,896 KB |
testcase_18 | AC | 113 ms
17,024 KB |
testcase_19 | AC | 117 ms
16,896 KB |
testcase_20 | AC | 118 ms
16,896 KB |
testcase_21 | AC | 116 ms
16,896 KB |
testcase_22 | AC | 120 ms
17,024 KB |
testcase_23 | AC | 123 ms
16,896 KB |
testcase_24 | AC | 122 ms
16,896 KB |
testcase_25 | AC | 118 ms
17,024 KB |
testcase_26 | AC | 126 ms
16,896 KB |
testcase_27 | AC | 177 ms
17,792 KB |
testcase_28 | AC | 170 ms
17,664 KB |
testcase_29 | AC | 169 ms
17,536 KB |
testcase_30 | AC | 166 ms
17,664 KB |
testcase_31 | AC | 170 ms
17,536 KB |
testcase_32 | AC | 148 ms
17,152 KB |
testcase_33 | AC | 154 ms
17,664 KB |
testcase_34 | AC | 155 ms
17,664 KB |
testcase_35 | AC | 167 ms
17,152 KB |
testcase_36 | AC | 157 ms
17,024 KB |
testcase_37 | AC | 170 ms
17,664 KB |
コンパイルメッセージ
main.cpp: In function 'void solve()': main.cpp:85:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 85 | for(auto [f, s] : mp){ | ^ main.cpp:101:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 101 | auto [f, s] = *it; | ^
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; // type typedef long long ll; typedef long double ld; template<class T> using pq = priority_queue<T>; template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>; template<class T> using v = vector<T>; #define pl pair<ll, ll> #define vl v<ll> #define vp v<pl> #define vm v<mint> // IN-OUT #define NYAN ios::sync_with_stdio(false);cin.tie(nullptr);cout<<fixed<<setprecision(15); void Yes(bool b=1) { cout << ( b == 1 ? "Yes" : "No" ) << "\n"; } void YES(bool b=1) { cout << ( b == 1 ? "YES" : "NO" ) << "\n"; } void No(bool b=1) { cout << ( b == 1 ? "No" : "Yes" ) << "\n"; } void NO(bool b=1) { cout << ( b == 1 ? "NO" : "YES" ) << "\n"; } void CIN() {} template <typename T, class... U> void CIN(T &t, U &...u) { cin >> t; CIN(u...); } void COUT() { cout << "\n"; } template <typename T, class... U, char sep = ' '> void COUT(const T &t, const U &...u) { cout << t; if (sizeof...(u)) cout << sep; COUT(u...); } #define dump(x) cerr << #x << ":"<< x << "\n"; #define vdump(x) rep(repeat, sz(x)) cerr << repeat << ":" << x[repeat] << "\n"; // macro #define bp __builtin_popcountll #define ALL(x) x.begin(),x.end() #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define reps(i, s, n) for (ll i = s; i < (ll)(n); i++) #define sz(x) (ll)x.size() ll xd[]={0, 1, 0, -1, 1, 1, -1, -1}; ll yd[]={1, 0, -1, 0, 1, -1, -1, 1}; // function template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } ll rmax(ll a, ll b){return max(a, b);} ll rmin(ll a, ll b){return min(a, b);} ll rsum(ll a, ll b){return a + b;} ll rzero(){return 0;} // constant long double PI = 3.14159265358979; #define INF32 2147483647 #define INF64 9223372036854775807 #define INF 922337203685477580 using mint = modint998244353; // using mint = modint1000000007; /* SOLVE BEGIN ************************************************************************** */ void solve() { ll n; cin >> n; vl l(n), a(n); v<vl> edge(n); reps(i, 1, n){ cin >> l[i] >> a[i]; a[i]--; edge[a[i]].emplace_back(i); } vl L(n, -1); L[0] = 0; queue<ll> Q; Q.emplace(0); while(sz(Q)){ auto now = Q.front(); Q.pop(); for(auto next : edge[now]){ L[next] = max(L[now], l[next]); Q.emplace(next); } } map<ll, ll> mp; rep(i, n) mp[L[i]]++; ll sum = 0; for(auto [f, s] : mp){ if(f == -1) continue; sum += s; mp[f] = sum; } ll q; cin >> q; while(q--){ ll op; cin >> op; ll x; cin >> x; if(op == 1){ auto it = mp.upper_bound(x); if(it == mp.begin()) cout << 0 << "\n"; else{ it--; auto [f, s] = *it; cout << s << "\n"; } }else{ x--; cout << L[x] << "\n"; } } } int main() { NYAN solve(); return 0; }