0% found this document useful (0 votes)
2 views

Tutorial(Chinese)

The document outlines various algorithmic problems and their complexities for the 2024 ICPC Asia EC Regionals Online Contest. Each section presents a different problem, such as 'Gambling on Choosing Regionals' and 'Mountain Booking', along with their respective computational complexities. The document serves as a tutorial for participants preparing for the contest.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Tutorial(Chinese)

The document outlines various algorithmic problems and their complexities for the 2024 ICPC Asia EC Regionals Online Contest. Each section presents a different problem, such as 'Gambling on Choosing Regionals' and 'Mountain Booking', along with their respective computational complexities. The document serves as a tutorial for participants preparing for the contest.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

The 2024 ICPC Asia EC Regionals Online Contest (II)

Tutorial

2024 9 21

A. Gambling on Choosing Regionals

min ci
O(n log n)

B. Mountain Booking
1 m i i
i Kruskal
O(n log n)
Kruskal
i ti qi O((ti + qi ) log n)
O(ti + qi ) Kruskal

LCT n, m, p, q
O(n log n)

C. Prefix of Suffixes
exkmp z kmp
exkmp
kmp border borderi s[1 . . . i]
border border z
zi i zi
zi
zi 1/
zi

s[n] = c zi s[n − i + 1] ̸= s[n]


zi n−i
i (s[1 . . . n − i] = s[i . . . n − 1])
(s[n − i + 1] ̸= s[n])

1
i → borderi n−i n−1

f ax,j x s[y+1] =
j y j ̸= c n−1 f ax,j
n−i
zi
i zj bj ai

O(n log n) O(n)

D. Query on Tree
ax , b x , t x ax x bx x 10
tx x 10
x k−1
bfs O(k)
ax bfs
bx tx bfs 10
O(k) bx tx
x x 10
x 10
bfs 10 10

10 dfs dfs bx , t x

O(nk + qk log n)

E. Escape
Sneaker
Sneaker Sneaker

1∼
n

Sneaker
2

O(n + m)

F. Tourist
O(n)

2
G. Game
a0 a1
a0 : a1 p0 = a0 +a1
, p1 = a0 +a1

O(T log(n + m))

H. Points Selection
query(a, b, c) query(≥ a, ≥ b, c)
a fc b
query(a, b, c) (x, y, w) f(c+w) mod n = min(f(c+w) mod n , max(fc , y))
y ≥ f(c+w) mod n m = max(f0 , f1 , . . . , fn−1 )
y≥m
k 2k n [0, n)
k
2 n n
O(n log n) k = O(log n) f f
O(log n) O( n log
k
n
)
∑n
k y<m O( logk n ) O( k=1
log n
k
) =
2
O(log n) f O(n) f

O(n log2 n)

I. Strange Binary
4 a0 = a1 = 0
a 1 2 −1−x
32
2i
ai−1 −1
x a0 0
O(T log n)

J. Stacking of Goods
ci
wi
O(n log n)

K. Match

f (A, B, k) A B Ai ⊕ Bj ≥ k
0, 1, 2, 3, …, min(|A|, |B|)
k 0 Ai , Bj
A 0 1 A0 , A1 B B0 , B 1 f (A0 , B0 , k), f (A1 , B1 , k)
A0 , B1 B1 , A 0 DP
k 1 f (A1 , B0 , k) f (A0 , B1 , k)
DP
O(n4 )

3
L. 502 Bad Gateway
[0, t) 1
0
c ∈ [1, t] c
0
c
c p= t
k (1−p)k

c−1 c−1 t
+ 1 + (1 − p) + (1 − p)2 + · · · = +
2 2 c
⌊√ ⌋ ⌈√ ⌉
c= 2t c= 2t
O(T log n)

You might also like