Submission #439675

#TimeUsernameProblemLanguageResultExecution timeMemory
439675tutisDungeons Game (IOI21_dungeons)C++17
13 / 100
3274 ms26128 KiB
#include "dungeons.h" #include <bits/stdc++.h> using namespace std; long long N; long long S[400002]; long long P[400002][19]; long long mx[400002][19]; long long W[400002]; long long L[400002][19]; void init(int n, vector<int> s, vector<int> p, vector<int> w, vector<int> l) { N = n; for (int i = 0; i < s.size(); i++) { S[i] = s[i]; mx[i][0] = s[i] - 1; } for (int i = 0; i < p.size(); i++) P[i][0] = p[i]; for (int i = 0; i < w.size(); i++) W[i] = w[i]; for (int i = 0; i < l.size(); i++) L[i][0] = l[i]; mx[n][0] = 1e17; L[n][0] = n; P[n][0] = 0; for (int t = 1; t < 19; t++) { for (int i = 0; i <= n; i++) { mx[i][t] = mx[L[i][t - 1]][t - 1] - P[i][t - 1]; L[i][t] = L[L[i][t - 1]][t - 1]; P[i][t] = P[i][t - 1] + P[L[i][t - 1]][t - 1]; } } } long long simulate(int x, int z) { long long s = z; while (x != N) { if (s >= S[x]) { s += S[x]; x = W[x]; } else { for (int t = 18; t >= 0; t--) { if (s <= mx[x][t]) { s += P[x][t]; x = L[x][t]; } } } } return s; }

Compilation message (stderr)

dungeons.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:12:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for (int i = 0; i < s.size(); i++)
      |                  ~~^~~~~~~~~~
dungeons.cpp:17:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for (int i = 0; i < p.size(); i++)
      |                  ~~^~~~~~~~~~
dungeons.cpp:19:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |  for (int i = 0; i < w.size(); i++)
      |                  ~~^~~~~~~~~~
dungeons.cpp:21:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for (int i = 0; i < l.size(); i++)
      |                  ~~^~~~~~~~~~
#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...