Submission #63025109


Source Code Expand

S = input().strip()
stack = []
brackets = {")": "(", "]": "[", ">": "<"}

l = set("([<")
r = set(")]>")

for ch in S:
    if ch in l:
        stack.append(ch)
    elif ch in r:
        if not stack or stack[-1] != brackets[ch]:
            print("No")
            exit()
        stack.pop()

print("Yes" if not stack else "No")

Submission Info

Submission Time
Task D - Colorful Bracket Sequence
User mu16
Language Python (PyPy 3.10-v7.3.12)
Score 400
Code Size 345 Byte
Status AC
Exec Time 71 ms
Memory 88852 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 40
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, random_00.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
Case Name Status Exec Time Memory
example_00.txt AC 56 ms 76668 KiB
example_01.txt AC 57 ms 76344 KiB
example_02.txt AC 56 ms 76516 KiB
hand_00.txt AC 71 ms 88636 KiB
hand_01.txt AC 65 ms 81732 KiB
hand_02.txt AC 71 ms 88616 KiB
hand_03.txt AC 56 ms 76620 KiB
hand_04.txt AC 70 ms 88652 KiB
hand_05.txt AC 57 ms 76436 KiB
hand_06.txt AC 56 ms 76488 KiB
random_00.txt AC 61 ms 84264 KiB
random_01.txt AC 71 ms 88852 KiB
random_02.txt AC 70 ms 87028 KiB
random_03.txt AC 70 ms 86880 KiB
random_04.txt AC 65 ms 87948 KiB
random_05.txt AC 70 ms 85944 KiB
random_06.txt AC 60 ms 81632 KiB
random_07.txt AC 64 ms 83032 KiB
random_08.txt AC 64 ms 84352 KiB
random_09.txt AC 69 ms 86088 KiB
random_10.txt AC 69 ms 81956 KiB
random_11.txt AC 68 ms 81684 KiB
random_12.txt AC 68 ms 81840 KiB
random_13.txt AC 64 ms 81732 KiB
random_14.txt AC 67 ms 81672 KiB
random_15.txt AC 66 ms 82120 KiB
random_16.txt AC 65 ms 81952 KiB
random_17.txt AC 62 ms 81752 KiB
random_18.txt AC 67 ms 81516 KiB
random_19.txt AC 61 ms 81392 KiB
random_20.txt AC 67 ms 81884 KiB
random_21.txt AC 67 ms 81896 KiB
random_22.txt AC 67 ms 81864 KiB
random_23.txt AC 67 ms 81516 KiB
random_24.txt AC 67 ms 81924 KiB
random_25.txt AC 62 ms 81344 KiB
random_26.txt AC 66 ms 81568 KiB
random_27.txt AC 66 ms 81956 KiB
random_28.txt AC 67 ms 81472 KiB
random_29.txt AC 65 ms 81636 KiB