제출 #551329

#제출 시각아이디문제언어결과실행 시간메모리
551329topovik던전 (IOI21_dungeons)C++17
89 / 100
7142 ms1983160 KiB
#include <bits/stdc++.h> #pragma GCC target("avx2") #define pb push_back #define f first #define s second #define pi acos(-1) using namespace std; typedef long long ll; typedef long double ld; const ll oo = 1e18; const ld eps = (ld)1 / oo; const ll N = 4e5 + 1; const ll M = 25; const int M1 = 6; const int M2 = 10; vector <int> s, p, w, l; int n; ll sum[M][N][M2]; ll mx[M][N][M2]; int nx[M][N][M2]; void init(int n1, vector <int> s1, vector <int> p1, vector <int> w1, vector <int> l1) { n = n1; s = s1, p = p1, w = w1, l = l1; for (register int pw = 0; pw < M; pw++) { for (int i = 0; i < n; i++) if (s[i] < (1ll << pw)) { nx[pw][i][0] = w[i]; mx[pw][i][0] = -oo; sum[pw][i][0] = s[i]; } else { nx[pw][i][0] = l[i]; mx[pw][i][0] = -s[i]; sum[pw][i][0] = p[i]; } nx[pw][n][0] = n; mx[pw][n][0] = -oo; sum[pw][n][0] = 0; for (register int j = 1; j < M2; j++) { for (register int i = 0; i <= n; i++) { nx[pw][i][j] = nx[pw][i][j - 1]; mx[pw][i][j] = mx[pw][i][j - 1]; sum[pw][i][j] = sum[pw][i][j - 1]; for (register int p = 1; p < M1; p++) { int c = nx[pw][i][j]; nx[pw][i][j] = nx[pw][c][j - 1]; mx[pw][i][j] = max(mx[pw][i][j], mx[pw][c][j - 1] + sum[pw][i][j]); sum[pw][i][j] += sum[pw][c][j - 1]; } } } } } ll simulate(int x, int y1) { ll y = y1; for (register int i = 0; i < M; i++) if (((1ll << i) <= y && (1ll << (i + 1)) > y) || i == M - 1) { for (register int j = M2 - 1; j >= 0; j--) { int c; for (c = 0; c < M1 && mx[i][x][j] + y < 0; c++) y += sum[i][x][j], x = nx[i][x][j]; if (c == M1) break; } if (x == n) return y; y += s[x]; x = w[x]; } return y; } //int main() //{ // srand(time(NULL)); // ll n, q; // cin >> n >> q; // vector <int> a(n), b(n), c(n), d(n); // for (ll i = 0; i < n; i++) cin >> a[i]; // for (ll i = 0; i < n; i++) cin >> b[i]; // for (ll i = 0; i < n; i++) cin >> c[i]; // for (ll i = 0; i < n; i++) cin >> d[i]; // init(n, a, b, c, d); // while (q--) // { // ll x, z; // cin >> x >> z; // cout << simulate(x, z) << endl; // } //}

컴파일 시 표준 에러 (stderr) 메시지

dungeons.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:31:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   31 |     for (register int pw = 0; pw < M; pw++)
      |                       ^~
dungeons.cpp:49:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   49 |         for (register int j = 1; j < M2; j++)
      |                           ^
dungeons.cpp:51:31: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   51 |             for (register int i = 0; i <= n; i++)
      |                               ^
dungeons.cpp:56:35: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   56 |                 for (register int p = 1; p < M1; p++)
      |                                   ^
dungeons.cpp: In function 'll simulate(int, int)':
dungeons.cpp:71:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   71 |     for (register int i = 0; i < M; i++)
      |                       ^
dungeons.cpp:74:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   74 |         for (register int j = M2 - 1; j >= 0; j--)
      |                           ^
#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...