제출 #1019235

#제출 시각아이디문제언어결과실행 시간메모리
1019235aykhn던전 (IOI21_dungeons)C++17
컴파일 에러
0 ms0 KiB
#include "dungeons.h" #include <bits/stdc++.h> using namespace std; #define inf 0x3F3F3F3F const int MXN = 4e5 + 5; const int LOG = 24; int N; array<int, 2> dpw[LOG][MXN], dplw[LOG][MXN]; int dplp[LOG][MXN]; int dep[MXN]; void init(int n, vector<int> s, vector<int> p, vector<int> w, vector<int> l) { N = n; for (int i = n - 1; i >= 0; i--) dep[i] = dep[w[i]] + s[i]; for (int i = 0; i < n; i++) { dpw[0][i] = {w[i], s[i] + dep[i]}; dplp[0][i] = l[i]; dplw[0][i] = {p[i], s[i]}; } dpw[0][n] = {n, -inf}, dplp[0][n] = n, dplw[0][n] = {0, -inf}; for (int lg = 1; lg < LOG; lg++) { for (int i = 0; i <= n; i++) { int pw = dpw[lg - 1][i][0], pl = dplp[lg - 1][i]; int ls = dplw[lg - 1][i][0], lm = dplw[lg - 1][pl][1]; dpw[lg][i] = {dpw[lg - 1][pw][0], max(dpw[lg - 1][i][1], dpw[lg - 1][pw][1])}; dplp[lg][i] = dplp[lg - 1][pl]; dplw[lg][i] = {ls + dplw[lg - 1][pl][0], min(dplw[lg - 1][i][1], lm - ls)}; } } } int simulate(int x, int z) { int val = z; while (1) { if (x == N) break; for (int i = LOG - 1; i >= 0; i--) { if (dep[x] + val >= dpw[i][x][1]) { val += dep[x] - dep[dpw[i][x][0]]; x = dpw[i][x][0]; } } if (x == N) break; for (int i = LOG - 1; i >= 0; i--) { if (val < dplw[i][x][1]) { val += dplw[i][x][0]; x = dplp[i][x]; } } } return val; }

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

dungeons.cpp:40:5: error: ambiguating new declaration of 'int simulate(int, int)'
   40 | int simulate(int x, int z)
      |     ^~~~~~~~
In file included from dungeons.cpp:1:
dungeons.h:4:11: note: old declaration 'long long int simulate(int, int)'
    4 | long long simulate(int x, int z);
      |           ^~~~~~~~