제출 #1057442

#제출 시각아이디문제언어결과실행 시간메모리
1057442mariaclara던전 (IOI21_dungeons)C++17
25 / 100
129 ms286588 KiB
#include "dungeons.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; const int MAXN = 5e4+5; #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() #define mk make_pair #define pb push_back #define fr first #define sc second int n; pair<int,ll> dp[7][25][MAXN]; vector<int> pos_s; void init(int n, vector<int> s, vector<int> p, vector<int> w, vector<int> l) { set<int> aux; n = sz(s); for(int i = 0; i < n; i++) aux.insert(s[i]); for(auto it : aux) pos_s.pb(it); s.pb(0); p.pb(0); w.pb(n); l.pb(n); for(int i = 0; i <= n; i++) { int it = lower_bound(all(pos_s), s[i]) - pos_s.begin(); for(int j = 0; j <= 6; j++) { if(it < j) dp[j][0][i] = {w[i], s[i]}; else dp[j][0][i] = {l[i], p[i]}; } } for(int t = 0; t <= 6; t++) { for(int bit = 1; bit < 25; bit++) { for(int i = 0; i <= n; i++) { dp[t][bit][i].fr = dp[t][bit-1][dp[t][bit-1][i].fr].fr; dp[t][bit][i].sc = dp[t][bit-1][i].sc + dp[t][bit-1][dp[t][bit-1][i].fr].sc; } } } } ll simulate(int x, int z) { int t = 0; ll ans = z; while(t < sz(pos_s)) { // dp[t][][x] for(int bit = 24; bit >= 0; bit--) { if(ans + dp[t][bit][x].sc < pos_s[t]) ans += dp[t][bit][x].sc, x = dp[t][bit][x].fr; } if(ans < pos_s[t]) ans += dp[t][0][x].sc, x = dp[t][0][x].fr; t++; } ans += dp[t][24][x].sc; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...