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>
using namespace std;
int n, ans;
string s;
vector <int> v;
int main(){
cin >> n >> s;
for(int i = 0; i < n; i ++)
if(s[i] == 'x')
v.push_back(i);
int sz = v.size();
for(int mask = 0; mask < (1 << sz); mask ++){
for(int i = 0; i < sz; i ++){
int bit = (1 << i) & mask;
if(bit)
s[v[i]] = ')';
else
s[v[i]] = '(';
}
bool f = 0;
for(int i = 0; i < n && !f; i ++){
for(int j = i; j < n && !f; j ++){
int sum = 0;
bool ff = 1;
for(int k = 0; k < n && ff; k ++){
if(k >= i && k <= j) {
if(s[k] == '(') s[k] = ')';
else s[k] = '(';
}
if(s[k] == '(')
sum ++;
else
sum --;
if(k >= i && k <= j){
if(s[k] == '(') s[k] = ')';
else s[k] = '(';
}
if(sum < 0) ff = 0;
}
if(sum != 0) ff = 0;
f |= ff;
}
}
ans += f;
}
cout << ans << endl;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |