Submission #1032826

# Submission time Handle Problem Language Result Execution time Memory
1032826 2024-07-24T09:27:09 Z 정희우(#10968) Match (CEOI16_match) C++17
37 / 100
26 ms 592 KB
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;
using lint = long long;
using intp = pair<int,int>;
using vint = vector<int>;

const int MAX_N=2010;

int n;
string str;
char ans[MAX_N];

int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin >> str;
    n=str.size();
    vector<char> st;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(j==i || ans[j]=='(' || st.empty() || st.back()!=str[j])
                st.push_back(str[j]);
            else
                st.pop_back();
        }
        if(st.empty())ans[i]='(';
        else ans[i]=')';
        st.clear();
    }
    if(ans[0]==')')
        cout << -1;
    else
        cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
7 Correct 7 ms 456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
7 Correct 7 ms 456 KB Output is correct
8 Runtime error 26 ms 592 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -