| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1131105 | sosuke | Editor (BOI15_edi) | Pypy 3 | 787 ms | 90116 KiB |
import math
MAX_N = 300001
MAX_D = math.ceil(math.log2(3 * (10^5)))
state = [0] * MAX_N
par = [[0] * MAX_D for _ in range(MAX_N)]
lev = [0] * MAX_N
def get_par(x: int, max_lev: int) -> int:
"""
get last op on active path of x with lev <= max_lev
"""
if lev[x] <= max_lev:
return x
for i in range(MAX_D - 1, -1, -1):
if lev[par[x][i]] > max_lev:
x = par[x][i]
return par[x][0]
n = int(input())
for i in range(1, n + 1):
state[i] = int(input())
if state[i] < 0:
lev[i] = -state[i]
z = get_par(i - 1, lev[i] - 1)
# must be something to undo
assert z > 0
par[i][0] = get_par(z - 1, lev[i] - 1)
# levels of ops in active path are strictly decreasing
assert lev[i] > lev[par[i][0]]
# prepare binary jumps
for j in range(1, MAX_D):
par[i][j] = par[par[i][j - 1]][j - 1]
# current active path is i, par[i], par[par[i]], ...
print(state[get_par(i, 0)])컴파일 시 표준 출력 (stdout) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
