Submission #852045

#TimeUsernameProblemLanguageResultExecution timeMemory
852045alex_2008Dungeons Game (IOI21_dungeons)C++17
Compilation error
0 ms0 KiB
#include "dungeons.h" #include <bits/stdc++.h> using namespace std; const long long N = 5e4 + 10; const long long INF = 3e18 + 10; struct esim { long long mindiff; long long pos; long long strength; }; esim dp[N][30][30]; long long NN; vector <long long> ss, pp, ww, ll; void init(int n, vector<int> s, vector<int> p, vector<int> w, vector<int> l) { NN = n; s.push_back(0); p.push_back(0); w.push_back(n); l.push_back(n); for (int i = 0; i <= n; i++) { ss.push_back(s[i]); } for (int i = 0; i <= n; i++) { pp.push_back(p[i]); } for (int i = 0; i <= n; i++) { ww.push_back(w[i]); } for (int i = 0; i <= n; i++) { ll.push_back(l[i]); } for (int k = 0; k < 30; k++) { for (int i = 0; i <= n; i++) { for (int j = 0; j < 30; j++) { if (k == 0) { dp[i][j][k].pos = ((1 << j) >= s[i]) ? w[i] : l[i]; dp[i][j][k].strength = ((1 << j) >= s[i]) ? s[i] : p[i]; dp[i][j][k].mindiff = ((1 << j) < s[i]) ? s[i] : INF; } else { dp[i][j][k].pos = dp[dp[i][j][k - 1].pos][j][k - 1].pos; dp[i][j][k].strength = dp[i][j][k - 1].strength + dp[dp[i][j][k - 1].pos][j][k - 1].strength; dp[i][j][k].mindiff = min(dp[i][j][k - 1].mindiff, dp[dp[i][j][k - 1].pos][j][k - 1].mindiff - dp[i][j][k - 1].strength); } } } } } long long simulate(int xx, int zz) { long long x = xx, z = zz; while (1) { int v = (int)(log2l(z)); if (v > 29) { for (int k = 29; k >= 0; k--) { if (dp[x][29][k].pos != NN) { z += dp[x][29][k].strength; x = dp[x][29][k].pos; } } z += dp[x][29][0]; return z; } for (int k = 29; k >= 0; k--) { if (dp[x][v][k].pos == NN || dp[x][v][k].mindiff <= z || (long long)(log2l(z + dp[x][v][k].strength)) > v) continue; z += dp[x][v][k].strength; x = dp[x][v][k].pos; } if (z >= ss[x]) { z += ss[x]; x = ww[x]; } else { z += pp[x]; x = ll[x]; } if (x == NN) return z; } return 0; }

Compilation message (stderr)

dungeons.cpp: In function 'long long int simulate(int, int)':
dungeons.cpp:60:14: error: no match for 'operator+=' (operand types are 'long long int' and 'esim')
   60 |            z += dp[x][29][0];
      |            ~~^~~~~~~~~~~~~~~