# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
73744 | 2018-08-28T20:31:46 Z | TadijaSebez | Security Gate (JOI18_security_gate) | C++11 | 5000 ms | 620 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair const int N=105; char s[N]; int n; bool good(int l, int r) { int c=0; for(int i=0;i<n;i++) { if(l<=i && i<=r) { if(s[i]==')') c++; else c--; } else { if(s[i]=='(') c++; else c--; } if(c<0) return 0; } return c==0; } bool Check() { int c=0,d=0,l,r,i,j; for(i=0;i<n;i++){ c+=s[i]=='('?1:-1;if(c<0) break;}if(!c) return 1;l=i; for(i=n-1;~i;i--){ d+=s[i]==')'?1:-1;if(d<0) break;}if(!d) return 1;r=i; for(i=0;i<=l;i++) for(j=r;j<n;j++) if(good(i,j)) return 1; if(good(0,-1)) return 1; return 0; } int main() { int i,j,k=0; scanf("%i",&n); scanf("%s",s); vector<int> pos; for(i=0;i<n;i++) if(s[i]=='x') pos.pb(i),k++; int sol=0; if(k>20 || (n&1)) return printf("0\n"),0; for(j=0;j<1<<k;j++) { for(i=0;i<k;i++) s[pos[i]]='('+((j>>i)&1); //cout << s << endl; if(Check()) sol++; } printf("%i\n",sol); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 488 KB | Output is correct |
3 | Correct | 3 ms | 488 KB | Output is correct |
4 | Correct | 3 ms | 488 KB | Output is correct |
5 | Correct | 3 ms | 488 KB | Output is correct |
6 | Correct | 4 ms | 488 KB | Output is correct |
7 | Correct | 2 ms | 520 KB | Output is correct |
8 | Correct | 3 ms | 520 KB | Output is correct |
9 | Correct | 3 ms | 568 KB | Output is correct |
10 | Correct | 3 ms | 568 KB | Output is correct |
11 | Correct | 3 ms | 604 KB | Output is correct |
12 | Correct | 3 ms | 604 KB | Output is correct |
13 | Correct | 3 ms | 604 KB | Output is correct |
14 | Correct | 2 ms | 604 KB | Output is correct |
15 | Correct | 2 ms | 604 KB | Output is correct |
16 | Correct | 3 ms | 604 KB | Output is correct |
17 | Correct | 2 ms | 604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 488 KB | Output is correct |
3 | Correct | 3 ms | 488 KB | Output is correct |
4 | Correct | 3 ms | 488 KB | Output is correct |
5 | Correct | 3 ms | 488 KB | Output is correct |
6 | Correct | 4 ms | 488 KB | Output is correct |
7 | Correct | 2 ms | 520 KB | Output is correct |
8 | Correct | 3 ms | 520 KB | Output is correct |
9 | Correct | 3 ms | 568 KB | Output is correct |
10 | Correct | 3 ms | 568 KB | Output is correct |
11 | Correct | 3 ms | 604 KB | Output is correct |
12 | Correct | 3 ms | 604 KB | Output is correct |
13 | Correct | 3 ms | 604 KB | Output is correct |
14 | Correct | 2 ms | 604 KB | Output is correct |
15 | Correct | 2 ms | 604 KB | Output is correct |
16 | Correct | 3 ms | 604 KB | Output is correct |
17 | Correct | 2 ms | 604 KB | Output is correct |
18 | Correct | 3 ms | 604 KB | Output is correct |
19 | Correct | 3 ms | 604 KB | Output is correct |
20 | Correct | 3 ms | 604 KB | Output is correct |
21 | Correct | 14 ms | 604 KB | Output is correct |
22 | Correct | 30 ms | 604 KB | Output is correct |
23 | Correct | 3 ms | 604 KB | Output is correct |
24 | Correct | 17 ms | 620 KB | Output is correct |
25 | Correct | 4 ms | 620 KB | Output is correct |
26 | Correct | 6 ms | 620 KB | Output is correct |
27 | Correct | 27 ms | 620 KB | Output is correct |
28 | Correct | 8 ms | 620 KB | Output is correct |
29 | Correct | 5 ms | 620 KB | Output is correct |
30 | Correct | 5 ms | 620 KB | Output is correct |
31 | Correct | 40 ms | 620 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 488 KB | Output is correct |
3 | Correct | 3 ms | 488 KB | Output is correct |
4 | Correct | 3 ms | 488 KB | Output is correct |
5 | Correct | 3 ms | 488 KB | Output is correct |
6 | Correct | 4 ms | 488 KB | Output is correct |
7 | Correct | 2 ms | 520 KB | Output is correct |
8 | Correct | 3 ms | 520 KB | Output is correct |
9 | Correct | 3 ms | 568 KB | Output is correct |
10 | Correct | 3 ms | 568 KB | Output is correct |
11 | Correct | 3 ms | 604 KB | Output is correct |
12 | Correct | 3 ms | 604 KB | Output is correct |
13 | Correct | 3 ms | 604 KB | Output is correct |
14 | Correct | 2 ms | 604 KB | Output is correct |
15 | Correct | 2 ms | 604 KB | Output is correct |
16 | Correct | 3 ms | 604 KB | Output is correct |
17 | Correct | 2 ms | 604 KB | Output is correct |
18 | Correct | 3 ms | 604 KB | Output is correct |
19 | Correct | 3 ms | 604 KB | Output is correct |
20 | Correct | 3 ms | 604 KB | Output is correct |
21 | Correct | 14 ms | 604 KB | Output is correct |
22 | Correct | 30 ms | 604 KB | Output is correct |
23 | Correct | 3 ms | 604 KB | Output is correct |
24 | Correct | 17 ms | 620 KB | Output is correct |
25 | Correct | 4 ms | 620 KB | Output is correct |
26 | Correct | 6 ms | 620 KB | Output is correct |
27 | Correct | 27 ms | 620 KB | Output is correct |
28 | Correct | 8 ms | 620 KB | Output is correct |
29 | Correct | 5 ms | 620 KB | Output is correct |
30 | Correct | 5 ms | 620 KB | Output is correct |
31 | Correct | 40 ms | 620 KB | Output is correct |
32 | Correct | 33 ms | 620 KB | Output is correct |
33 | Correct | 10 ms | 620 KB | Output is correct |
34 | Correct | 991 ms | 620 KB | Output is correct |
35 | Correct | 23 ms | 620 KB | Output is correct |
36 | Correct | 50 ms | 620 KB | Output is correct |
37 | Correct | 775 ms | 620 KB | Output is correct |
38 | Execution timed out | 5029 ms | 620 KB | Time limit exceeded |
39 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 488 KB | Output is correct |
3 | Correct | 3 ms | 488 KB | Output is correct |
4 | Correct | 3 ms | 488 KB | Output is correct |
5 | Correct | 3 ms | 488 KB | Output is correct |
6 | Correct | 4 ms | 488 KB | Output is correct |
7 | Correct | 2 ms | 520 KB | Output is correct |
8 | Correct | 3 ms | 520 KB | Output is correct |
9 | Correct | 3 ms | 568 KB | Output is correct |
10 | Correct | 3 ms | 568 KB | Output is correct |
11 | Correct | 3 ms | 604 KB | Output is correct |
12 | Correct | 3 ms | 604 KB | Output is correct |
13 | Correct | 3 ms | 604 KB | Output is correct |
14 | Correct | 2 ms | 604 KB | Output is correct |
15 | Correct | 2 ms | 604 KB | Output is correct |
16 | Correct | 3 ms | 604 KB | Output is correct |
17 | Correct | 2 ms | 604 KB | Output is correct |
18 | Correct | 3 ms | 604 KB | Output is correct |
19 | Correct | 3 ms | 604 KB | Output is correct |
20 | Correct | 3 ms | 604 KB | Output is correct |
21 | Correct | 14 ms | 604 KB | Output is correct |
22 | Correct | 30 ms | 604 KB | Output is correct |
23 | Correct | 3 ms | 604 KB | Output is correct |
24 | Correct | 17 ms | 620 KB | Output is correct |
25 | Correct | 4 ms | 620 KB | Output is correct |
26 | Correct | 6 ms | 620 KB | Output is correct |
27 | Correct | 27 ms | 620 KB | Output is correct |
28 | Correct | 8 ms | 620 KB | Output is correct |
29 | Correct | 5 ms | 620 KB | Output is correct |
30 | Correct | 5 ms | 620 KB | Output is correct |
31 | Correct | 40 ms | 620 KB | Output is correct |
32 | Correct | 33 ms | 620 KB | Output is correct |
33 | Correct | 10 ms | 620 KB | Output is correct |
34 | Correct | 991 ms | 620 KB | Output is correct |
35 | Correct | 23 ms | 620 KB | Output is correct |
36 | Correct | 50 ms | 620 KB | Output is correct |
37 | Correct | 775 ms | 620 KB | Output is correct |
38 | Execution timed out | 5029 ms | 620 KB | Time limit exceeded |
39 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 488 KB | Output is correct |
3 | Correct | 3 ms | 488 KB | Output is correct |
4 | Correct | 3 ms | 488 KB | Output is correct |
5 | Correct | 3 ms | 488 KB | Output is correct |
6 | Correct | 4 ms | 488 KB | Output is correct |
7 | Correct | 2 ms | 520 KB | Output is correct |
8 | Correct | 3 ms | 520 KB | Output is correct |
9 | Correct | 3 ms | 568 KB | Output is correct |
10 | Correct | 3 ms | 568 KB | Output is correct |
11 | Correct | 3 ms | 604 KB | Output is correct |
12 | Correct | 3 ms | 604 KB | Output is correct |
13 | Correct | 3 ms | 604 KB | Output is correct |
14 | Correct | 2 ms | 604 KB | Output is correct |
15 | Correct | 2 ms | 604 KB | Output is correct |
16 | Correct | 3 ms | 604 KB | Output is correct |
17 | Correct | 2 ms | 604 KB | Output is correct |
18 | Correct | 3 ms | 604 KB | Output is correct |
19 | Correct | 3 ms | 604 KB | Output is correct |
20 | Correct | 3 ms | 604 KB | Output is correct |
21 | Correct | 14 ms | 604 KB | Output is correct |
22 | Correct | 30 ms | 604 KB | Output is correct |
23 | Correct | 3 ms | 604 KB | Output is correct |
24 | Correct | 17 ms | 620 KB | Output is correct |
25 | Correct | 4 ms | 620 KB | Output is correct |
26 | Correct | 6 ms | 620 KB | Output is correct |
27 | Correct | 27 ms | 620 KB | Output is correct |
28 | Correct | 8 ms | 620 KB | Output is correct |
29 | Correct | 5 ms | 620 KB | Output is correct |
30 | Correct | 5 ms | 620 KB | Output is correct |
31 | Correct | 40 ms | 620 KB | Output is correct |
32 | Correct | 33 ms | 620 KB | Output is correct |
33 | Correct | 10 ms | 620 KB | Output is correct |
34 | Correct | 991 ms | 620 KB | Output is correct |
35 | Correct | 23 ms | 620 KB | Output is correct |
36 | Correct | 50 ms | 620 KB | Output is correct |
37 | Correct | 775 ms | 620 KB | Output is correct |
38 | Execution timed out | 5029 ms | 620 KB | Time limit exceeded |
39 | Halted | 0 ms | 0 KB | - |