Submission #63051749


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
stack<char> st;
for (char c : s) {
if (c == '(' || c == '[' || c == '<') st.push(c);
else {
if (st.empty()) cout << "No", exit(0);
char top = st.top();
if ( (c == ')' && top == '(') ||(c == ']' && top == '[') || (c == '>' && top == '<') ) st.pop();
else cout << "No", exit(0);
}
}
if (st.empty()) cout << "Yes";
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>

using namespace std;

int main() {
    string s;
    cin >> s; 

    stack<char> st;

    for (char c : s) {
        if (c == '(' || c == '[' || c == '<') st.push(c);
        else {
            if (st.empty()) cout << "No", exit(0); 
            char top = st.top();
            if ( (c == ')' && top == '(') ||(c == ']' && top == '[') || (c == '>' && top == '<') ) st.pop(); 
            else cout << "No", exit(0); 
        }
    }

    if (st.empty()) cout << "Yes";
    else cout << "No";

    return 0;
}

Submission Info

Submission Time
Task D - Colorful Bracket Sequence
User JimmyCao123
Language C++ 20 (gcc 12.2)
Score 400
Code Size 559 Byte
Status AC
Exec Time 5 ms
Memory 3996 KB

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 1 ms 3544 KB
example_01.txt AC 1 ms 3544 KB
example_02.txt AC 1 ms 3496 KB
hand_00.txt AC 4 ms 3604 KB
hand_01.txt AC 4 ms 3668 KB
hand_02.txt AC 4 ms 3740 KB
hand_03.txt AC 1 ms 3544 KB
hand_04.txt AC 4 ms 3688 KB
hand_05.txt AC 1 ms 3612 KB
hand_06.txt AC 1 ms 3608 KB
random_00.txt AC 3 ms 3924 KB
random_01.txt AC 4 ms 3668 KB
random_02.txt AC 4 ms 3668 KB
random_03.txt AC 4 ms 3864 KB
random_04.txt AC 3 ms 3876 KB
random_05.txt AC 4 ms 3668 KB
random_06.txt AC 3 ms 3876 KB
random_07.txt AC 3 ms 3812 KB
random_08.txt AC 4 ms 3860 KB
random_09.txt AC 4 ms 3800 KB
random_10.txt AC 4 ms 3668 KB
random_11.txt AC 4 ms 3600 KB
random_12.txt AC 4 ms 3536 KB
random_13.txt AC 4 ms 3736 KB
random_14.txt AC 4 ms 3664 KB
random_15.txt AC 4 ms 3776 KB
random_16.txt AC 4 ms 3868 KB
random_17.txt AC 3 ms 3812 KB
random_18.txt AC 4 ms 3664 KB
random_19.txt AC 4 ms 3768 KB
random_20.txt AC 5 ms 3736 KB
random_21.txt AC 5 ms 3740 KB
random_22.txt AC 5 ms 3664 KB
random_23.txt AC 5 ms 3684 KB
random_24.txt AC 5 ms 3616 KB
random_25.txt AC 3 ms 3816 KB
random_26.txt AC 4 ms 3804 KB
random_27.txt AC 4 ms 3668 KB
random_28.txt AC 5 ms 3532 KB
random_29.txt AC 4 ms 3996 KB


2025-04-17 (Thu)
16:47:51 +00:00