# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
537560 | jamezzz | Security Gate (JOI18_security_gate) | C++17 | 5092 ms | 300 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>
using namespace std;
#define sf scanf
#define pf printf
int n,x,pos[25];
char s[105];
int main(){
sf("%d",&n);
assert(n<=100);
sf(" %s",&s);
for(int i=0;i<n;++i){
if(s[i]=='x'){
pos[x]=i;
++x;
}
}
assert(x<=20);
int ans=0;
for(int i=0;i<(1<<x);++i){
for(int j=0;j<x;++j){
if(i&(1<<j))s[pos[j]]=')';
else s[pos[j]]='(';
}
bool val=false;
for(int i=0;i<n;++i){
for(int j=0;j<n;++j){
int cnt=0;bool pos=true;
for(int k=0;k<n;++k){
int mult=1;
if(i<=k&&k<=j)mult=-1;
if(s[k]=='(')cnt+=mult;
else cnt-=mult;
if(cnt<0){
pos=false;
break;
}
}
if(cnt!=0)pos=false;
if(pos){
val=true;
break;
}
}
if(val)break;
}
if(val)++ans;
}
pf("%d\n",ans);
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |