Submission #453626

#TimeUsernameProblemLanguageResultExecution timeMemory
453626flappybirdDungeons Game (IOI21_dungeons)C++17
Compilation error
0 ms0 KiB
#include "dungeons.h" #include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2") using namespace std; typedef long long ll; typedef pair<ll, ll> pll; vector<pll> win, lose; //next int nxt[9][40][404040], limit[9][40][404040]; ll delta[9][40][404040]; int N; void init(int n, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l) { N = n; ll i; win.resize(N + 1); lose.resize(N + 1); for (i = 0; i < N; i++) { win[i] = { w[i], s[i] }; lose[i] = { l[i], p[i] }; } ll k; for (k = 0; k < MAXI; k++) { ll low, high; low = 1 << (3 * k); high = 1 << (3 * (k + 1)); for (i = 0; i < N; i++) { if (s[i] < low) { nxt[k][0][i] = win[i].first; delta[k][0][i] = win[i].second; limit[k][0][i] = INF; } else if (s[i] >= high) { nxt[k][0][i] = lose[i].first; delta[k][0][i] = lose[i].second; limit[k][0][i] = s[i]; } else { nxt[k][0][i] = lose[i].first; delta[k][0][i] = lose[i].second; limit[k][0][i] = s[i]; } } nxt[k][0][N] = N; delta[k][0][N] = 0; limit[k][0][N] = INF; ll j; for (j = 1; j < k + 1; j++) { for (i = 0; i <= N; i++) { ll v = nxt[k][j - 1][i]; nxt[k][j][i] = nxt[k][j - 1][v]; delta[k][j][i] = delta[k][j - 1][i] + delta[k][j - 1][v]; limit[k][j][i] = (int)max(0LL, min((ll)limit[k][j - 1][v] - delta[k][j - 1][i], (ll)limit[k][j - 1][i])); } } } return; } ll get(ll x) { return 0; } long long f(ll x, ll z) { ll i; for (i = 0; i < MAXI; i++) { ll low, high; high = 1 << (3 * (i + 1)); if (i == MAXI - 1) return z + get(x); if (high <= z) continue; ll k; ll c = 1; while (c) { c = 0; if (high <= z) break; for (k = 3 * i + 2; k >= 0; k--) { if (limit[i][k][x] > z) { c = 1; z += delta[i][k][x]; x = nxt[i][k][x]; } if (high <= z) break; if (x == N) return z; } if (high <= z) break; if (c == 0) { if (z >= win[x].second) z += win[x].second, x = win[x].first; else z += lose[x].second, x = lose[x].first; if (x == N) return z; if (high <= z) break; c = 1; } if (x == N) return z; if (high <= z) break; } } return z; } long long simulate(int x, int z) { return f(x, z); }

Compilation message (stderr)

dungeons.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:27:18: error: 'MAXI' was not declared in this scope
   27 |  for (k = 0; k < MAXI; k++) {
      |                  ^~~~
dungeons.cpp:35:22: error: 'INF' was not declared in this scope
   35 |     limit[k][0][i] = INF;
      |                      ^~~
dungeons.cpp:50:20: error: 'INF' was not declared in this scope
   50 |   limit[k][0][N] = INF;
      |                    ^~~
dungeons.cpp: In function 'long long int f(ll, ll)':
dungeons.cpp:70:18: error: 'MAXI' was not declared in this scope
   70 |  for (i = 0; i < MAXI; i++) {
      |                  ^~~~
dungeons.cpp:71:6: warning: unused variable 'low' [-Wunused-variable]
   71 |   ll low, high;
      |      ^~~