Submission #828922

#TimeUsernameProblemLanguageResultExecution timeMemory
828922LiudasDungeons Game (IOI21_dungeons)C++17
0 / 100
7071 ms1084 KiB
#include "dungeons.h" #include <vector> #include <cassert> #include <cstdio> #include <iostream> using namespace std; struct node{ int ws, ls, w, l, dep; vector<int> child; vector<int> cv; }; struct node2{ vector<int> par; }; vector<node> tree; void init(int n, vector<int> s, vector<int> p, vector<int> w, vector<int> l){ tree.resize(n+1); for(int i = 0; i < n; i ++){ tree[i].ws = s[i]; tree[i].ls = p[i]; tree[i].w = w[i]; tree[i].l = l[i]; tree[i].child.push_back(l[i]); tree[i].cv.push_back(p[i]); } tree[n].child.push_back(n); tree[n].cv.push_back(0); for(int i = 0; i < 25; i ++){ for(int j = 0; j <= n; j ++){ tree[j].child.push_back(tree[tree[j].child[i]].child[i]); tree[j].cv.push_back(tree[tree[j].child[i]].cv[i] + tree[j].cv[i]); } } for(auto i : tree){ for(int j : i.child){ cout << j << " "; } cout << endl; for(int j : i.cv){ cout << j << " "; } cout << endl; } } long long simulate(int x, int z){ long long ans = z; while(x != tree.size()){ if(ans >= tree[x].ws){ ans += tree[x].ws; x = tree[x].w; } else{ int p = 0; while(tree[x].cv[p+1] + ans < tree[x].ws){ p++; } ans += tree[x].cv[p]; x = tree[x].child[p]; } } return ans; }

Compilation message (stderr)

dungeons.cpp: In function 'long long int simulate(int, int)':
dungeons.cpp:47:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<node>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     while(x != tree.size()){
      |           ~~^~~~~~~~~~~~~~
#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...