# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
407117 | 2021-05-18T13:51:40 Z | 79brue | Security Gate (JOI18_security_gate) | C++14 | 5000 ms | 324 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n; char s[102]; int pref[102]; int ans; void dfs(int x){ if(x == n+1){ int firstNegative = 101, lastNegative = -1; for(int i=1; i<=n; i++) if(pref[i] < 0) firstNegative = min(firstNegative, i); for(int i=1; i<=n; i++) if(pref[i] - pref[n] < 0) lastNegative = i; if(pref[n] == 0 && lastNegative == -1){ ans++; return; } bool able = 0; for(int i=1; i<=n && i<=firstNegative; i++){ bool good = 0; for(int j=i; j<=n; j++){ if(pref[j] > 2 * pref[i-1]) break; if(pref[n] - 2 * (pref[j] - pref[i-1]) == 0 && j > lastNegative){ good = 1; break; } } if(good){ able = 1; break; } } if(able) ans++; return; } if(s[x] == '(' || s[x] == ')'){ pref[x] = pref[x-1] + (s[x] == '(' ? 1 : -1); dfs(x+1); return; } s[x] = '('; pref[x] = pref[x-1] + 1; dfs(x+1); s[x] = ')'; pref[x] = pref[x-1] - 1; dfs(x+1); s[x] = 'x'; return; } int main(){ scanf("%d %s", &n, s+1); if(n%2){ printf("0"); return 0; } dfs(1); printf("%d", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 292 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 292 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 1 ms | 204 KB | Output is correct |
21 | Correct | 5 ms | 204 KB | Output is correct |
22 | Correct | 7 ms | 296 KB | Output is correct |
23 | Correct | 1 ms | 204 KB | Output is correct |
24 | Correct | 5 ms | 204 KB | Output is correct |
25 | Correct | 1 ms | 204 KB | Output is correct |
26 | Correct | 1 ms | 204 KB | Output is correct |
27 | Correct | 6 ms | 288 KB | Output is correct |
28 | Correct | 2 ms | 204 KB | Output is correct |
29 | Correct | 1 ms | 204 KB | Output is correct |
30 | Correct | 1 ms | 204 KB | Output is correct |
31 | Correct | 2 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 292 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 1 ms | 204 KB | Output is correct |
21 | Correct | 5 ms | 204 KB | Output is correct |
22 | Correct | 7 ms | 296 KB | Output is correct |
23 | Correct | 1 ms | 204 KB | Output is correct |
24 | Correct | 5 ms | 204 KB | Output is correct |
25 | Correct | 1 ms | 204 KB | Output is correct |
26 | Correct | 1 ms | 204 KB | Output is correct |
27 | Correct | 6 ms | 288 KB | Output is correct |
28 | Correct | 2 ms | 204 KB | Output is correct |
29 | Correct | 1 ms | 204 KB | Output is correct |
30 | Correct | 1 ms | 204 KB | Output is correct |
31 | Correct | 2 ms | 204 KB | Output is correct |
32 | Correct | 9 ms | 204 KB | Output is correct |
33 | Correct | 3 ms | 204 KB | Output is correct |
34 | Correct | 146 ms | 288 KB | Output is correct |
35 | Correct | 7 ms | 204 KB | Output is correct |
36 | Correct | 19 ms | 204 KB | Output is correct |
37 | Correct | 89 ms | 204 KB | Output is correct |
38 | Correct | 4651 ms | 272 KB | Output is correct |
39 | Correct | 8 ms | 292 KB | Output is correct |
40 | Correct | 311 ms | 272 KB | Output is correct |
41 | Correct | 2997 ms | 272 KB | Output is correct |
42 | Correct | 1148 ms | 324 KB | Output is correct |
43 | Correct | 245 ms | 272 KB | Output is correct |
44 | Correct | 34 ms | 204 KB | Output is correct |
45 | Correct | 2729 ms | 268 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 292 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 1 ms | 204 KB | Output is correct |
21 | Correct | 5 ms | 204 KB | Output is correct |
22 | Correct | 7 ms | 296 KB | Output is correct |
23 | Correct | 1 ms | 204 KB | Output is correct |
24 | Correct | 5 ms | 204 KB | Output is correct |
25 | Correct | 1 ms | 204 KB | Output is correct |
26 | Correct | 1 ms | 204 KB | Output is correct |
27 | Correct | 6 ms | 288 KB | Output is correct |
28 | Correct | 2 ms | 204 KB | Output is correct |
29 | Correct | 1 ms | 204 KB | Output is correct |
30 | Correct | 1 ms | 204 KB | Output is correct |
31 | Correct | 2 ms | 204 KB | Output is correct |
32 | Correct | 9 ms | 204 KB | Output is correct |
33 | Correct | 3 ms | 204 KB | Output is correct |
34 | Correct | 146 ms | 288 KB | Output is correct |
35 | Correct | 7 ms | 204 KB | Output is correct |
36 | Correct | 19 ms | 204 KB | Output is correct |
37 | Correct | 89 ms | 204 KB | Output is correct |
38 | Correct | 4651 ms | 272 KB | Output is correct |
39 | Correct | 8 ms | 292 KB | Output is correct |
40 | Correct | 311 ms | 272 KB | Output is correct |
41 | Correct | 2997 ms | 272 KB | Output is correct |
42 | Correct | 1148 ms | 324 KB | Output is correct |
43 | Correct | 245 ms | 272 KB | Output is correct |
44 | Correct | 34 ms | 204 KB | Output is correct |
45 | Correct | 2729 ms | 268 KB | Output is correct |
46 | Correct | 1 ms | 204 KB | Output is correct |
47 | Correct | 1 ms | 204 KB | Output is correct |
48 | Correct | 1 ms | 204 KB | Output is correct |
49 | Execution timed out | 5021 ms | 204 KB | Time limit exceeded |
50 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 292 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 1 ms | 204 KB | Output is correct |
21 | Correct | 5 ms | 204 KB | Output is correct |
22 | Correct | 7 ms | 296 KB | Output is correct |
23 | Correct | 1 ms | 204 KB | Output is correct |
24 | Correct | 5 ms | 204 KB | Output is correct |
25 | Correct | 1 ms | 204 KB | Output is correct |
26 | Correct | 1 ms | 204 KB | Output is correct |
27 | Correct | 6 ms | 288 KB | Output is correct |
28 | Correct | 2 ms | 204 KB | Output is correct |
29 | Correct | 1 ms | 204 KB | Output is correct |
30 | Correct | 1 ms | 204 KB | Output is correct |
31 | Correct | 2 ms | 204 KB | Output is correct |
32 | Correct | 9 ms | 204 KB | Output is correct |
33 | Correct | 3 ms | 204 KB | Output is correct |
34 | Correct | 146 ms | 288 KB | Output is correct |
35 | Correct | 7 ms | 204 KB | Output is correct |
36 | Correct | 19 ms | 204 KB | Output is correct |
37 | Correct | 89 ms | 204 KB | Output is correct |
38 | Correct | 4651 ms | 272 KB | Output is correct |
39 | Correct | 8 ms | 292 KB | Output is correct |
40 | Correct | 311 ms | 272 KB | Output is correct |
41 | Correct | 2997 ms | 272 KB | Output is correct |
42 | Correct | 1148 ms | 324 KB | Output is correct |
43 | Correct | 245 ms | 272 KB | Output is correct |
44 | Correct | 34 ms | 204 KB | Output is correct |
45 | Correct | 2729 ms | 268 KB | Output is correct |
46 | Correct | 1 ms | 204 KB | Output is correct |
47 | Correct | 1 ms | 204 KB | Output is correct |
48 | Correct | 1 ms | 204 KB | Output is correct |
49 | Execution timed out | 5021 ms | 204 KB | Time limit exceeded |
50 | Halted | 0 ms | 0 KB | - |