제출 #815348

#제출 시각아이디문제언어결과실행 시간메모리
815348eltu0815던전 (IOI21_dungeons)C++17
100 / 100
4154 ms814556 KiB
#include "dungeons.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; int N; const int MX = 8; int pos[MX][400001][21], mn[MX][400001][21], sum[MX][400001][21]; ll dp[400001]; vector<int> s, p, w, l; void init(int n, std::vector<int> S, std::vector<int> P, std::vector<int> W, std::vector<int> L) { N = n; s = S; p = P, w = W, l = L; for(int j = 0; j < MX; ++j) { for(int i = 0; i < N; ++i) { pos[j][i][0] = (1 << 3 * j) <= S[i] ? L[i] : W[i]; sum[j][i][0] = (1 << 3 * j) <= S[i] ? P[i] : S[i]; mn[j][i][0] = (1 << 3 * j) <= S[i] ? S[i] : (int)(1e9); } pos[j][N][0] = N, sum[j][N][0] = mn[j][N][0] = (int)(1e9); } for(int k = 0; k < MX; ++k) for(int j = 1; j <= 20; ++j) { for(int i = 0; i <= N; ++i) { pos[k][i][j] = pos[k][pos[k][i][j - 1]][j - 1]; sum[k][i][j] = sum[k][pos[k][i][j - 1]][j - 1] + sum[k][i][j - 1]; mn[k][i][j] = min(mn[k][i][j - 1], mn[k][pos[k][i][j - 1]][j - 1] - sum[k][i][j - 1]); sum[k][i][j] = min(sum[k][i][j], (int)(1e9)); mn[k][i][j] = max(mn[k][i][j], 0); } } for(int i = n - 1; i >= 0; --i) dp[i] = dp[W[i]] + S[i]; return; } long long simulate(int x, int z) { ll ans = z; for(int k = 0; k < MX; ++k) { while(ans < (1 << 3 * k + 3)) { for(int j = 20; j >= 0; --j) { if(pos[k][x][j] != N && sum[k][x][j] + ans < (1 << 3 * k + 3) && mn[k][x][j] > ans) { ans += sum[k][x][j], x = pos[k][x][j]; } } if(s[x] <= ans) ans += s[x], x = w[x]; else if(ans < (1 << 3 * k + 3)) ans += p[x], x = l[x]; if(x == N) return ans; } } return ans + dp[x]; }

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

dungeons.cpp: In function 'long long int simulate(int, int)':
dungeons.cpp:41:33: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   41 |         while(ans < (1 << 3 * k + 3)) {
      |                           ~~~~~~^~~
dungeons.cpp:43:74: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   43 |                 if(pos[k][x][j] != N && sum[k][x][j] + ans < (1 << 3 * k + 3) && mn[k][x][j] > ans) {
      |                                                                    ~~~~~~^~~
dungeons.cpp:48:39: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   48 |             else if(ans < (1 << 3 * k + 3)) ans += p[x], x = l[x];
      |                                 ~~~~~~^~~
#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...