Submission #52846

# Submission time Handle Problem Language Result Execution time Memory
52846 2018-06-27T05:09:03 Z 노영훈(#1382) Match (CEOI16_match) C++11
0 / 100
3 ms 488 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=500010, inf=2e9;

int n;

int cnt[30];
char S[MX], R[MX];

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>(S+1);
    for(int i=1; S[i]!=0; i++) n=i;
    for(int i=1; i<=n; i++)
        cnt[S[i]-'a']++;
    for(int i=0; i<='z'-'a'; i++)
        if(cnt[i]%2==1){
            cout<<-1;
            return 0;
        }

    int now[30]={};
    for(int i=1; i<=n; i++){
        int x=S[i]-'a';
        now[x]++;
        if(now[x]*2<=cnt[x]) cout<<'(';
        else cout<<')';
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Incorrect 3 ms 488 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Incorrect 3 ms 488 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Incorrect 3 ms 488 KB Output isn't correct
3 Halted 0 ms 0 KB -