# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
814316 | 2023-08-08T06:49:23 Z | 반딧불(#10119) | Security Gate (JOI18_security_gate) | C++17 | 1669 ms | 340 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]; int spsR[302][7]; vector<int> vec[202]; bool goodString(){ for(int i=1; i<=n; i++) sum[i] = sum[i-1] + (filled[i] == '(' ? 1 : -1), spsR[i][0] = sum[i]; for(int d=1; d<7; d++) for(int i=1; i<=n; i++) spsR[i][d] = max(spsR[i][d-1], (i+(1<<(d-1))) <= n ? spsR[i+(1<<(d-1))][d-1] : INT_MIN); for(int i=0; i<=200; i++) vec[i].clear(); int minUntilNow = sum[n], pnt = 1; for(int i=n; i>=1; i--){ minUntilNow = min(minUntilNow, sum[i]); if(minUntilNow < sum[n]){ pnt = i+1; break; } } if(pnt == 1 && sum[n] == 0) return true; for(int i=pnt; i<=n; i++) vec[sum[i] + 100].push_back(i); for(int i=1; i<=n; i++){ if(sum[i-1] < 0) break; int j = i-1; /// j���� ���� int stype = (sum[n] + 2 * sum[i-1]) / 2 + 100; if(stype > 200 || stype < 0) continue; for(int d=6; d>=0; d--){ if(spsR[j+1][d] <= sum[i-1] * 2) j += (1<<d); } int idx = upper_bound(vec[stype].begin(), vec[stype].end(), j) - vec[stype].begin() - 1; if(idx >= 0 && i <= vec[stype][idx] && vec[stype][idx] <= j) return true; } return false; } int main(){ scanf("%d %s", &n, str+1); if(n%2){ puts("0"); return 0; } 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 | 320 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 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 | 340 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 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 | 320 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 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 | 340 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 3 ms | 212 KB | Output is correct |
21 | Correct | 5 ms | 212 KB | Output is correct |
22 | Correct | 6 ms | 212 KB | Output is correct |
23 | Correct | 1 ms | 212 KB | Output is correct |
24 | Correct | 6 ms | 212 KB | Output is correct |
25 | Correct | 1 ms | 212 KB | Output is correct |
26 | Correct | 1 ms | 312 KB | Output is correct |
27 | Correct | 5 ms | 316 KB | Output is correct |
28 | Correct | 2 ms | 212 KB | Output is correct |
29 | Correct | 1 ms | 312 KB | Output is correct |
30 | Correct | 1 ms | 212 KB | Output is correct |
31 | Correct | 6 ms | 212 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 | 320 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 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 | 340 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 3 ms | 212 KB | Output is correct |
21 | Correct | 5 ms | 212 KB | Output is correct |
22 | Correct | 6 ms | 212 KB | Output is correct |
23 | Correct | 1 ms | 212 KB | Output is correct |
24 | Correct | 6 ms | 212 KB | Output is correct |
25 | Correct | 1 ms | 212 KB | Output is correct |
26 | Correct | 1 ms | 312 KB | Output is correct |
27 | Correct | 5 ms | 316 KB | Output is correct |
28 | Correct | 2 ms | 212 KB | Output is correct |
29 | Correct | 1 ms | 312 KB | Output is correct |
30 | Correct | 1 ms | 212 KB | Output is correct |
31 | Correct | 6 ms | 212 KB | Output is correct |
32 | Correct | 25 ms | 212 KB | Output is correct |
33 | Correct | 7 ms | 212 KB | Output is correct |
34 | Correct | 540 ms | 296 KB | Output is correct |
35 | Correct | 23 ms | 212 KB | Output is correct |
36 | Correct | 73 ms | 332 KB | Output is correct |
37 | Correct | 325 ms | 312 KB | Output is correct |
38 | Correct | 1669 ms | 312 KB | Output is correct |
39 | Correct | 23 ms | 212 KB | Output is correct |
40 | Correct | 1179 ms | 308 KB | Output is correct |
41 | Correct | 1507 ms | 300 KB | Output is correct |
42 | Correct | 1310 ms | 300 KB | Output is correct |
43 | Correct | 663 ms | 300 KB | Output is correct |
44 | Correct | 89 ms | 212 KB | Output is correct |
45 | Correct | 1569 ms | 300 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 | 320 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 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 | 340 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 3 ms | 212 KB | Output is correct |
21 | Correct | 5 ms | 212 KB | Output is correct |
22 | Correct | 6 ms | 212 KB | Output is correct |
23 | Correct | 1 ms | 212 KB | Output is correct |
24 | Correct | 6 ms | 212 KB | Output is correct |
25 | Correct | 1 ms | 212 KB | Output is correct |
26 | Correct | 1 ms | 312 KB | Output is correct |
27 | Correct | 5 ms | 316 KB | Output is correct |
28 | Correct | 2 ms | 212 KB | Output is correct |
29 | Correct | 1 ms | 312 KB | Output is correct |
30 | Correct | 1 ms | 212 KB | Output is correct |
31 | Correct | 6 ms | 212 KB | Output is correct |
32 | Correct | 25 ms | 212 KB | Output is correct |
33 | Correct | 7 ms | 212 KB | Output is correct |
34 | Correct | 540 ms | 296 KB | Output is correct |
35 | Correct | 23 ms | 212 KB | Output is correct |
36 | Correct | 73 ms | 332 KB | Output is correct |
37 | Correct | 325 ms | 312 KB | Output is correct |
38 | Correct | 1669 ms | 312 KB | Output is correct |
39 | Correct | 23 ms | 212 KB | Output is correct |
40 | Correct | 1179 ms | 308 KB | Output is correct |
41 | Correct | 1507 ms | 300 KB | Output is correct |
42 | Correct | 1310 ms | 300 KB | Output is correct |
43 | Correct | 663 ms | 300 KB | Output is correct |
44 | Correct | 89 ms | 212 KB | Output is correct |
45 | Correct | 1569 ms | 300 KB | Output is correct |
46 | Correct | 1 ms | 212 KB | Output is correct |
47 | Correct | 0 ms | 312 KB | Output is correct |
48 | Correct | 1 ms | 212 KB | Output is correct |
49 | Incorrect | 1 ms | 212 KB | Output isn't correct |
50 | 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 | 320 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 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 | 340 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 3 ms | 212 KB | Output is correct |
21 | Correct | 5 ms | 212 KB | Output is correct |
22 | Correct | 6 ms | 212 KB | Output is correct |
23 | Correct | 1 ms | 212 KB | Output is correct |
24 | Correct | 6 ms | 212 KB | Output is correct |
25 | Correct | 1 ms | 212 KB | Output is correct |
26 | Correct | 1 ms | 312 KB | Output is correct |
27 | Correct | 5 ms | 316 KB | Output is correct |
28 | Correct | 2 ms | 212 KB | Output is correct |
29 | Correct | 1 ms | 312 KB | Output is correct |
30 | Correct | 1 ms | 212 KB | Output is correct |
31 | Correct | 6 ms | 212 KB | Output is correct |
32 | Correct | 25 ms | 212 KB | Output is correct |
33 | Correct | 7 ms | 212 KB | Output is correct |
34 | Correct | 540 ms | 296 KB | Output is correct |
35 | Correct | 23 ms | 212 KB | Output is correct |
36 | Correct | 73 ms | 332 KB | Output is correct |
37 | Correct | 325 ms | 312 KB | Output is correct |
38 | Correct | 1669 ms | 312 KB | Output is correct |
39 | Correct | 23 ms | 212 KB | Output is correct |
40 | Correct | 1179 ms | 308 KB | Output is correct |
41 | Correct | 1507 ms | 300 KB | Output is correct |
42 | Correct | 1310 ms | 300 KB | Output is correct |
43 | Correct | 663 ms | 300 KB | Output is correct |
44 | Correct | 89 ms | 212 KB | Output is correct |
45 | Correct | 1569 ms | 300 KB | Output is correct |
46 | Correct | 1 ms | 212 KB | Output is correct |
47 | Correct | 0 ms | 312 KB | Output is correct |
48 | Correct | 1 ms | 212 KB | Output is correct |
49 | Incorrect | 1 ms | 212 KB | Output isn't correct |
50 | Halted | 0 ms | 0 KB | - |