# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1117660 |
2024-11-24T07:14:21 Z |
vjudge1 |
Match (CEOI16_match) |
C++14 |
|
1 ms |
336 KB |
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define F first
#define S second
#define ll long long
#define int ll
#define pii pair<int, int>
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define M_PI 3.14159265358979323846
#define all(v) v.begin(), v.end()
#define pss pair<string, string>
#define no cout<<"No"<<endl;
#define yes cout<<"Yes"<<endl;
#define imp cout<<-1<<endl;
#define flu cout.flush();
#define Endl endl
const int N = 100009;
const int mod = 1e9+7;
void solve(){
string s;
cin>>s;
int n;
n=s.size();
for(int i=0; i<(1<<n); i++){
string a="";
for(int j=0; j<n; j++){
if(i&(1<<j)){
a=a+"(";
}
else{
a=a+")";
}
}
int qwe=0, yx=0;
for(int i=0; i<n; i++){
if(a[i]==')'){
qwe--;
}
else{
qwe++;
}
if(qwe<0){
yx++;
break;
}
}
if(yx!=0 or qwe!=0){
continue;
}
vector<char>st;
for(int i=0; i<n; i++){
if(a[i]=='('){
st.pb(s[i]);
}
else{
char let=st[st.size()-1];
if(s[i]==let){
st.pop_back();
}
else{
yx++;
break;
}
}
}
if(yx==0){
cout<<a<<endl;
return;
}
}
imp;
}
signed main(){
io;
int t=1;
//cin>>t;
while(t--){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |