Submission #26539

# Submission time Handle Problem Language Result Execution time Memory
26539 2017-07-02T13:39:49 Z bill_kondo Match (CEOI16_match) C++14
0 / 100
0 ms 2020 KB
#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define pb push_back

typedef pair<char,int>pci;

string s;

string solve(){
	string ret;
	int n = (int)s.size();
	ret.resize(n+1);
	vector<pci>stk;
	FOR(i,0,n-1){
		if(stk.empty()) stk.pb(pci(s[i],i));
		else{
			if(stk.back().first == s[i]){
				ret[stk.back().second] = '(';
				ret[i] = ')';
				stk.pop_back();
			}
			else stk.pb(pci(s[i],i));
		}
	}
	if(!stk.empty()){
		cout << "-1\n";
		exit(0);
	}
	return ret;
}

int main(){
	cin >> s;
	cout << solve() << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2020 KB Output isn't correct
2 Halted 0 ms 0 KB -