# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
953760 | ramalzaher | Superpozicija (COCI22_superpozicija) | C++14 | 55 ms | 3412 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define int int64_t
#define FOR(i, n ) for(int i= 0; i < n ; i++ )
#define all(x) a.begin() , a.end()
#define sz size()
using namespace std;
const int N = 2e5 ;
int n ;string s;int a[N] , b[N] ;
signed main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int T; cin >> T ;
while(T--){
cin >> n ;
cin >> s ;
map<int,int> mp ;
FOR(i , n )
{
cin >> a[i] >> b[i];
mp[a[i]] =1 ;
}
string ans = "" ;
FOR(i , s.sz )
if(mp[i]==0){
char temp = s[i];
ans+=temp;}
cout<<ans<<endl;
stack<char> st ;st.push(s[0]) ;
for(int i =1; i < ans.sz ; i ++ )
{
if(st.sz != 0 && (st.top() == '(' && ans[i]==')'))
st.pop() ;else
st.push(ans[i]) ;
}
if(st.sz == 0 ){
FOR(i ,n )
cout<<1<<' ' ;
}else cout<<-1<<endl ;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |