Submission #63034659


Source Code Expand

from collections import defaultdict

d = hashMap = {')': '(', '>': '<', ']': '['}
st = []
s = list(input())

for i in range(len(s)):
    #it's (<[
    if s[i] not in d:
        parenthesis = s[i]
        st.append(parenthesis)
    else: #it's )>]
        if s[i] not in d or not st:
            print("No")
            exit(0)
        else:
            current = st.pop()
            if current != hashMap[s[i]]:
                print("No")
                exit(0)

if not st:
    print("Yes")
else:
    print("No")

Submission Info

Submission Time
Task D - Colorful Bracket Sequence
User lamooon
Language Python (CPython 3.11.4)
Score 400
Code Size 539 Byte
Status AC
Exec Time 52 ms
Memory 11796 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 12 ms 9168 KiB
example_01.txt AC 11 ms 9128 KiB
example_02.txt AC 12 ms 9096 KiB
hand_00.txt AC 49 ms 11796 KiB
hand_01.txt AC 49 ms 10716 KiB
hand_02.txt AC 46 ms 11696 KiB
hand_03.txt AC 11 ms 9044 KiB
hand_04.txt AC 48 ms 11796 KiB
hand_05.txt AC 12 ms 9232 KiB
hand_06.txt AC 12 ms 9176 KiB
random_00.txt AC 21 ms 11448 KiB
random_01.txt AC 52 ms 11664 KiB
random_02.txt AC 47 ms 11404 KiB
random_03.txt AC 46 ms 11476 KiB
random_04.txt AC 29 ms 11700 KiB
random_05.txt AC 47 ms 10812 KiB
random_06.txt AC 15 ms 10824 KiB
random_07.txt AC 29 ms 10748 KiB
random_08.txt AC 30 ms 11360 KiB
random_09.txt AC 48 ms 10752 KiB
random_10.txt AC 47 ms 10832 KiB
random_11.txt AC 50 ms 10744 KiB
random_12.txt AC 45 ms 10748 KiB
random_13.txt AC 37 ms 10784 KiB
random_14.txt AC 51 ms 10864 KiB
random_15.txt AC 39 ms 10740 KiB
random_16.txt AC 38 ms 10708 KiB
random_17.txt AC 21 ms 10788 KiB
random_18.txt AC 48 ms 10772 KiB
random_19.txt AC 21 ms 10756 KiB
random_20.txt AC 50 ms 10816 KiB
random_21.txt AC 51 ms 10812 KiB
random_22.txt AC 52 ms 10704 KiB
random_23.txt AC 52 ms 10820 KiB
random_24.txt AC 49 ms 10880 KiB
random_25.txt AC 22 ms 10752 KiB
random_26.txt AC 48 ms 10748 KiB
random_27.txt AC 48 ms 10744 KiB
random_28.txt AC 48 ms 10724 KiB
random_29.txt AC 36 ms 10704 KiB