Submission #550144

#TimeUsernameProblemLanguageResultExecution timeMemory
550144Theo830Dungeons Game (IOI21_dungeons)C++17
11 / 100
7030 ms19760 KiB
#include <bits/stdc++.h> using namespace std; typedef int ll; const ll INF = 1e9+7; const ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ll,ii> #define iii2 pair<ii,ll> #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///Training #include "dungeons.h" //void init(int n, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l); //long long simulate(int x, int z); vector<int>S,P,W,L; void init(int n, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l){ S = s; P = p; W = w; L = l; return; } long long simulate(int x, int z){ int n = S.size(); long long ans = z; ll cur = x; while(1){ bool v[n] = {0}; vll vis; ll mini = 1e9; ll sum = 0; while(1){ v[cur] = 1; vis.pb(cur); if(ans >= S[cur]){ ans += S[cur]; cur = W[cur]; } else{ ans += P[cur]; cur = L[cur]; } if(cur == n){ break; } } if(cur == n){ break; } reverse(all(vis)); while(vis.back() != cur){ vis.pop_back(); } for(auto x:vis){ if(S[x] > ans){ mini = min(mini,S[x]); sum += P[x]; } else{ sum += S[x]; } } if(mini != (ll)(1e9)){ ans += sum * ((mini - ans) / sum); } } return ans; } /* static int n, q; static std::vector<int> s, p, z; static std::vector<int> w, l, x; static std::vector<long long> answer; int main() { assert(scanf("%d %d", &n, &q) == 2); s.resize(n); p.resize(n); w.resize(n); l.resize(n); x.resize(q); z.resize(q); answer.resize(q); for (int i = 0; i < n; i++) { assert(scanf("%d", &s[i]) == 1); } for (int i = 0; i < n; i++) { assert(scanf("%d", &p[i]) == 1); } for (int i = 0; i < n; i++) { assert(scanf("%d", &w[i]) == 1); } for (int i = 0; i < n; i++) { assert(scanf("%d", &l[i]) == 1); } init(n, s, p, w, l); for (int i = 0; i < q; i++) { assert(scanf("%d %d", &x[i], &z[i]) == 2); answer[i] = simulate(x[i], z[i]); } fclose(stdin); for (int i = 0; i < q; i++) { printf("%lld\n", answer[i]); } fclose(stdout); return 0; } */
#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...