Submission #680773

#TimeUsernameProblemLanguageResultExecution timeMemory
680773BlagojDungeons Game (IOI21_dungeons)C++17
11 / 100
7038 ms42188 KiB
#include "dungeons.h" #include <bits/stdc++.h> using namespace std; vector<int> str, ls, wn, lsd; vector<long long> d; int N, mx = 0; void init(int n, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l) { d.resize(n + 2, 0); N = n, str = s, ls = p, wn = w, lsd = l; vector<int> g[n + 2]; for (int i = 0; i < w.size(); i++) { g[w[i]].push_back(i); } for (auto x : s) mx = max(mx, x); int pos = n; set<int> st; queue<pair<long long, int>> q; q.push({0, n}); bool visited[n + 2]; memset(visited, 0, sizeof(visited)); visited[n] = 1; while (q.size() > 0) { auto node = q.front(); q.pop(); for (auto x : g[node.second]) { if (!visited[x]) { visited[x] = 1; d[x] = node.first + s[x]; q.push({d[x], x}); } } } return; } long long simulate(int x, int z) { long long ans = z; while (x != N) { if (ans >= mx) { ans += d[x]; break; } if (ans >= str[x]) { ans += str[x]; x = wn[x]; } else { ans += ls[x]; x = lsd[x]; } } return ans; }

Compilation message (stderr)

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