제출 #815381

#제출 시각아이디문제언어결과실행 시간메모리
815381eltu0815던전 (IOI21_dungeons)C++17
63 / 100
3634 ms498872 KiB
#include "dungeons.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; int N; int pos[6][400001][17], mn[6][400001][17], sum[6][400001][17]; ll dp[400000]; 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, w = W; for(int j = 0; j < 6; ++j) { for(int i = 0; i < N; ++i) { pos[j][i][0] = (1 << 4 * j) <= S[i] ? L[i] : W[i]; sum[j][i][0] = (1 << 4 * j) <= S[i] ? P[i] : S[i]; mn[j][i][0] = (1 << 4 * 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 < 6; ++k) for(int j = 1; j <= 16; ++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 < 6; ++k) { while(ans < (1 << 4 * k + 4)) { for(int j = 16; j >= 0; --j) { if(pos[k][x][j] != N && sum[k][x][j] + ans < (1 << 4 * k + 4) && 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 << 4 * k + 4)) ans += sum[k][x][0], x = pos[k][x][0]; if(x == N) return ans; } } return ans + dp[x]; }

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

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