Advertisement
Derga

Untitled

Aug 22nd, 2023
535
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. INF = 10 ** 9
  2.  
  3. fence = [(INF, 0)]
  4. q = int(input())
  5. for i in range(q):
  6.     query = list(map(int, input().split()))
  7.     if query[0] == 1:
  8.         r = query[1]
  9.         c = query[2]
  10.         while len(fence) > 0 and r >= fence[-1][0]:
  11.             fence.pop()
  12.         fence.append((r, c))
  13.     else:
  14.         x = query[1]
  15.         L = 0
  16.         R = len(fence)
  17.         while R - L > 1:
  18.             M = (L + R) // 2
  19.             if fence[M][0] >= x:
  20.                 L = M
  21.             else:
  22.                 R = M
  23.         print(fence[L][1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement