Submission #63036287


Source Code Expand

import copy
import numpy as np
import math
import random
from collections import deque

S = input()

p_start = ["(", "[", "<"]
p_end = [")", "]", ">"]
p_with = ["()", "[]", "<>"]

d = deque([])
ans = True

for s in S:
    if s in p_start:
        d.append(s)
    elif s in p_end:
        if len(d) == 0: 
            ans = False
            break
        _d = d.pop()
        if not (_d + s) in p_with:
            ans = False
            break
if len(d) != 0:
    ans = False

if ans:
    print("Yes")
else:
    print("No")

Submission Info

Submission Time
Task D - Colorful Bracket Sequence
User zenmaaa
Language Python (CPython 3.11.4)
Score 400
Code Size 556 Byte
Status AC
Exec Time 126 ms
Memory 33012 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 79 ms 32036 KiB
example_01.txt AC 79 ms 31824 KiB
example_02.txt AC 80 ms 31836 KiB
hand_00.txt AC 119 ms 32940 KiB
hand_01.txt AC 115 ms 32536 KiB
hand_02.txt AC 126 ms 32968 KiB
hand_03.txt AC 79 ms 32036 KiB
hand_04.txt AC 114 ms 32904 KiB
hand_05.txt AC 78 ms 31640 KiB
hand_06.txt AC 79 ms 32076 KiB
random_00.txt AC 84 ms 32304 KiB
random_01.txt AC 116 ms 33012 KiB
random_02.txt AC 119 ms 32748 KiB
random_03.txt AC 116 ms 32740 KiB
random_04.txt AC 92 ms 32956 KiB
random_05.txt AC 117 ms 32320 KiB
random_06.txt AC 80 ms 32532 KiB
random_07.txt AC 96 ms 32552 KiB
random_08.txt AC 94 ms 32640 KiB
random_09.txt AC 118 ms 32592 KiB
random_10.txt AC 116 ms 32276 KiB
random_11.txt AC 116 ms 32400 KiB
random_12.txt AC 118 ms 32280 KiB
random_13.txt AC 103 ms 32300 KiB
random_14.txt AC 115 ms 32400 KiB
random_15.txt AC 107 ms 32384 KiB
random_16.txt AC 109 ms 32220 KiB
random_17.txt AC 89 ms 32504 KiB
random_18.txt AC 115 ms 32504 KiB
random_19.txt AC 87 ms 32564 KiB
random_20.txt AC 117 ms 32440 KiB
random_21.txt AC 116 ms 32448 KiB
random_22.txt AC 117 ms 32424 KiB
random_23.txt AC 119 ms 32244 KiB
random_24.txt AC 116 ms 32316 KiB
random_25.txt AC 88 ms 32396 KiB
random_26.txt AC 117 ms 32568 KiB
random_27.txt AC 119 ms 32460 KiB
random_28.txt AC 116 ms 32308 KiB
random_29.txt AC 102 ms 32392 KiB