# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
813965 | 2023-08-08T04:47:11 Z | 반딧불(#10119) | Security Gate (JOI18_security_gate) | C++17 | 5000 ms | 308 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n; char str[302]; char filled[302]; vector<int> blanks; int ans; int sum[302]; bool goodString(){ for(int i=1; i<=n; i++) sum[i] = sum[i-1] + (filled[i] == '(' ? 1 : -1); for(int i=1; i<=n; i++){ for(int j=i; j<=n; j++){ /// [i, j] ������ ������ if(i>1 && *min_element(sum+1, sum+i) < 0) continue; if(sum[i-1] * 2 - *max_element(sum+i+1, sum+j+1) < 0) continue; if(sum[n] != 2 * (sum[j] - sum[i-1])) continue; if((sum[i-1] - sum[j]) * 2 + *min_element(sum+j, sum+n+1) < 0) continue; return true; } } return false; } int main(){ scanf("%d %s", &n, str+1); for(int i=1; i<=n; i++) if(str[i] == 'x') blanks.push_back(i); int k = (int)blanks.size(); for(int d=0; d<(1<<k); d++){ for(int i=1; i<=n; i++) filled[i] = str[i]; for(int i=0; i<k; i++) filled[blanks[i]] = ((d>>i)&1) ? '(' : ')'; if(goodString()) ans++; } printf("%d", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 300 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 2 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 300 KB | Output is correct |
10 | Correct | 4 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 304 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 2 ms | 308 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 300 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 2 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 300 KB | Output is correct |
10 | Correct | 4 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 304 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 2 ms | 308 KB | Output is correct |
18 | Correct | 2 ms | 304 KB | Output is correct |
19 | Correct | 51 ms | 280 KB | Output is correct |
20 | Correct | 9 ms | 212 KB | Output is correct |
21 | Correct | 521 ms | 284 KB | Output is correct |
22 | Correct | 340 ms | 280 KB | Output is correct |
23 | Correct | 70 ms | 284 KB | Output is correct |
24 | Correct | 685 ms | 280 KB | Output is correct |
25 | Correct | 1 ms | 212 KB | Output is correct |
26 | Correct | 5 ms | 300 KB | Output is correct |
27 | Correct | 295 ms | 280 KB | Output is correct |
28 | Correct | 8 ms | 304 KB | Output is correct |
29 | Correct | 7 ms | 296 KB | Output is correct |
30 | Correct | 9 ms | 304 KB | Output is correct |
31 | Correct | 109 ms | 284 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 300 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 2 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 300 KB | Output is correct |
10 | Correct | 4 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 304 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 2 ms | 308 KB | Output is correct |
18 | Correct | 2 ms | 304 KB | Output is correct |
19 | Correct | 51 ms | 280 KB | Output is correct |
20 | Correct | 9 ms | 212 KB | Output is correct |
21 | Correct | 521 ms | 284 KB | Output is correct |
22 | Correct | 340 ms | 280 KB | Output is correct |
23 | Correct | 70 ms | 284 KB | Output is correct |
24 | Correct | 685 ms | 280 KB | Output is correct |
25 | Correct | 1 ms | 212 KB | Output is correct |
26 | Correct | 5 ms | 300 KB | Output is correct |
27 | Correct | 295 ms | 280 KB | Output is correct |
28 | Correct | 8 ms | 304 KB | Output is correct |
29 | Correct | 7 ms | 296 KB | Output is correct |
30 | Correct | 9 ms | 304 KB | Output is correct |
31 | Correct | 109 ms | 284 KB | Output is correct |
32 | Correct | 70 ms | 292 KB | Output is correct |
33 | Correct | 19 ms | 212 KB | Output is correct |
34 | Correct | 3830 ms | 280 KB | Output is correct |
35 | Correct | 40 ms | 212 KB | Output is correct |
36 | Execution timed out | 5070 ms | 212 KB | Time limit exceeded |
37 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 300 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 2 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 300 KB | Output is correct |
10 | Correct | 4 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 304 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 2 ms | 308 KB | Output is correct |
18 | Correct | 2 ms | 304 KB | Output is correct |
19 | Correct | 51 ms | 280 KB | Output is correct |
20 | Correct | 9 ms | 212 KB | Output is correct |
21 | Correct | 521 ms | 284 KB | Output is correct |
22 | Correct | 340 ms | 280 KB | Output is correct |
23 | Correct | 70 ms | 284 KB | Output is correct |
24 | Correct | 685 ms | 280 KB | Output is correct |
25 | Correct | 1 ms | 212 KB | Output is correct |
26 | Correct | 5 ms | 300 KB | Output is correct |
27 | Correct | 295 ms | 280 KB | Output is correct |
28 | Correct | 8 ms | 304 KB | Output is correct |
29 | Correct | 7 ms | 296 KB | Output is correct |
30 | Correct | 9 ms | 304 KB | Output is correct |
31 | Correct | 109 ms | 284 KB | Output is correct |
32 | Correct | 70 ms | 292 KB | Output is correct |
33 | Correct | 19 ms | 212 KB | Output is correct |
34 | Correct | 3830 ms | 280 KB | Output is correct |
35 | Correct | 40 ms | 212 KB | Output is correct |
36 | Execution timed out | 5070 ms | 212 KB | Time limit exceeded |
37 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 300 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 2 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 300 KB | Output is correct |
10 | Correct | 4 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 304 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 2 ms | 308 KB | Output is correct |
18 | Correct | 2 ms | 304 KB | Output is correct |
19 | Correct | 51 ms | 280 KB | Output is correct |
20 | Correct | 9 ms | 212 KB | Output is correct |
21 | Correct | 521 ms | 284 KB | Output is correct |
22 | Correct | 340 ms | 280 KB | Output is correct |
23 | Correct | 70 ms | 284 KB | Output is correct |
24 | Correct | 685 ms | 280 KB | Output is correct |
25 | Correct | 1 ms | 212 KB | Output is correct |
26 | Correct | 5 ms | 300 KB | Output is correct |
27 | Correct | 295 ms | 280 KB | Output is correct |
28 | Correct | 8 ms | 304 KB | Output is correct |
29 | Correct | 7 ms | 296 KB | Output is correct |
30 | Correct | 9 ms | 304 KB | Output is correct |
31 | Correct | 109 ms | 284 KB | Output is correct |
32 | Correct | 70 ms | 292 KB | Output is correct |
33 | Correct | 19 ms | 212 KB | Output is correct |
34 | Correct | 3830 ms | 280 KB | Output is correct |
35 | Correct | 40 ms | 212 KB | Output is correct |
36 | Execution timed out | 5070 ms | 212 KB | Time limit exceeded |
37 | Halted | 0 ms | 0 KB | - |