# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
548258 |
2022-04-12T20:04:46 Z |
leaked |
Match (CEOI16_match) |
C++17 |
|
1 ms |
1192 KB |
#include <bits/stdc++.h>
#define f first
#define s second
#define m_p make_pair
#define vec vector
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)(x).size()
#define pw(x) (1LL<<(x))
#define fast_prep ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
//#define int long long
template<class T> bool umin(T &a,const T &b){return (a>b?a=b,1:0);}
template<class T> bool umax(T &a,const T &b){return (a<b?a=b,1:0);}
const int N=1e5+1;
struct dsu{
int p[N];
void make(int v){
p[v]=v;
}
dsu(){
iota(p,p+N,0);
}
int get(int v){
return p[v]=(p[v]==v?v:get(p[v]));
}
}lt,rt;
signed main(){
fast_prep;
string s;
cin>>s;
int n=sz(s);
vec<int> lft(n),rgt(n);
string ans(n,'-');
stack<int> st;
for(int i=0;i<n;i++){
if(!sz(st)) st.push(i),ans[i]='(';
else{
if(s[st.top()]==s[i]){
ans[i]=')';
st.pop();
}
else{
ans[i]='(';
st.push(i);
}
}
}
if(sz(st)){
cout<<-1;
return 0;
}
cout<<ans;
return 0;
}
/*
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1192 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1192 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1192 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |