Submission #69490444


Source Code Expand

from atcoder.segtree import SegTree

N, Q = map(int, input().split())
INF = 1 << 20
stmin = SegTree(min, INF, N)
stmax = SegTree(max, -1, N)

for _ in range(Q):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if (b - a) % N == 0 or (stmin.prod(a + 1, b) > a and stmax.prod(a + 1, b) < b):
        stmin.set(b, a)
        stmin.set(a, b)
        stmax.set(b, a)
        stmax.set(a, b)
        print("Yes")
    else:
        print("No")

Submission Info

Submission Time
Task F - Adding Chords
User mo12412
Language Python (PyPy 3.10-v7.3.12)
Score 525
Code Size 470 Byte
Status AC
Exec Time 1687 ms
Memory 135300 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 525 / 525
Status
AC × 2
AC × 34
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All min.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
min.txt AC 127 ms 84456 KiB
random_01.txt AC 920 ms 133916 KiB
random_02.txt AC 434 ms 133988 KiB
random_03.txt AC 911 ms 130088 KiB
random_04.txt AC 705 ms 130896 KiB
random_05.txt AC 908 ms 134100 KiB
random_06.txt AC 628 ms 134372 KiB
random_07.txt AC 936 ms 133792 KiB
random_08.txt AC 741 ms 133784 KiB
random_09.txt AC 1159 ms 135300 KiB
random_10.txt AC 305 ms 133984 KiB
random_11.txt AC 1129 ms 133792 KiB
random_12.txt AC 706 ms 132452 KiB
random_13.txt AC 1382 ms 134812 KiB
random_14.txt AC 1170 ms 135056 KiB
random_15.txt AC 1357 ms 133532 KiB
random_16.txt AC 1119 ms 111948 KiB
random_17.txt AC 1032 ms 134032 KiB
random_18.txt AC 1046 ms 134148 KiB
random_19.txt AC 1323 ms 134148 KiB
random_20.txt AC 1241 ms 133936 KiB
random_21.txt AC 1060 ms 134192 KiB
random_22.txt AC 1272 ms 134192 KiB
random_23.txt AC 1030 ms 133888 KiB
random_24.txt AC 1173 ms 133964 KiB
random_25.txt AC 892 ms 133848 KiB
random_26.txt AC 1627 ms 133856 KiB
random_27.txt AC 1687 ms 134016 KiB
random_28.txt AC 713 ms 134136 KiB
random_29.txt AC 709 ms 133900 KiB
random_30.txt AC 971 ms 134368 KiB
random_31.txt AC 933 ms 134036 KiB
sample_01.txt AC 121 ms 84388 KiB
sample_02.txt AC 158 ms 134336 KiB