Submission #16928237


Source Code Expand

Copy
N, *XY = map(int, open(0).read().split())
X, Y = XY[::2], XY[1::2]
XtoY = [0] * (N+1)
for x, y in zip(X,Y):
  XtoY[x] = y

ans = [0] * (N+1)
l = 1
min_y = N + 1
for x in range(1, N+1):
  min_y = min(min_y, XtoY[x])
  if x + min_y == N+1:
    for i in range(l, x+1):
      ans[i] = x - l + 1
    l, min_y = x+1, N+1

for x in X:
  print(ans[x])

Submission Info

Submission Time
Task A - Reachable Towns
User maspy
Language Python (3.8.2)
Score 300
Code Size 360 Byte
Status
Exec Time 363 ms
Memory 55240 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
× 2
× 24
Set Name Test Cases
Sample example_00, example_01
All example_00, example_01, manyperm_00, manyperm_01, manyperm_02, manyperm_03, max_random_00, max_random_01, random_00, random_01, small_00, small_01, small_02, small_03, small_04, small_05, small_06, small_07, small_08, small_09, special1_00, special1_01, special1_02, special1_03
Case Name Status Exec Time Memory
example_00 26 ms 9164 KB
example_01 19 ms 9156 KB
manyperm_00 344 ms 54768 KB
manyperm_01 335 ms 54972 KB
manyperm_02 338 ms 54796 KB
manyperm_03 335 ms 55240 KB
max_random_00 358 ms 54908 KB
max_random_01 363 ms 55032 KB
random_00 238 ms 38308 KB
random_01 271 ms 43888 KB
small_00 27 ms 9092 KB
small_01 19 ms 9216 KB
small_02 20 ms 8936 KB
small_03 21 ms 8932 KB
small_04 28 ms 8972 KB
small_05 24 ms 8920 KB
small_06 23 ms 8924 KB
small_07 26 ms 8928 KB
small_08 23 ms 8928 KB
small_09 24 ms 8920 KB
special1_00 235 ms 38356 KB
special1_01 271 ms 43888 KB
special1_02 106 ms 21260 KB
special1_03 305 ms 47736 KB