# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
56691 | 2018-07-12T07:47:51 Z | 윤교준(#1618) | Security Gate (JOI18_security_gate) | C++11 | 5000 ms | 844 KB |
#include <bits/stdc++.h> #define pb push_back #define eb emplace_back #define sz(V) ((int)(V).size()) #define allv(V) ((V).begin()),((V).end()) #define befv(V) ((V)[(sz(V)-2)]) #define sorv(V) sort(allv(V)) #define revv(V) reverse(allv(V)) #define univ(V) (V).erase(unique(allv(V)),(V).end()) #define clv(V) (V).clear() #define upmin(a,b) (a)=min((a),(b)) #define upmax(a,b) (a)=max((a),(b)) #define rb(x) ((x)&(-(x))) #define INF (0x3f3f3f3f) #define INFLL (0x3f3f3f3f3f3f3f3fll) using namespace std; typedef pair<int, int> pii; const int MOD = 1000000007; const int MAXN = 305; int A[MAXN]; int N, Ans; bool f() { int r = 0; for(int i = 1; i <= N; i++) { r += A[i]; if(r < 0) return false; } return !r; } int main() { scanf("%d", &N); for(int i = 1; i <= N; i++) { char c; scanf(" %c", &c); if('x' != c) A[i] = ('(' == c ? 1 : -1); } vector<int> V; for(int i = 1; i <= N; i++) if(!A[i]) V.eb(i); for(int n = sz(V), key = 0; key < (1<<n); key++) { for(int i = 0; i < n; i++) A[V[i]] = (key & (1<<i)) ? 1 : -1; bool flag = false; for(int s = 1; s <= N && !flag; s++) for(int e = 1; e <= N; e++) { for(int i = s; i <= e; i++) A[i] = -A[i]; if(f()) flag = true; for(int i = s; i <= e; i++) A[i] = -A[i]; if(flag) break; } Ans += flag; } cout << Ans << endl; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 420 KB | Output is correct |
4 | Correct | 3 ms | 420 KB | Output is correct |
5 | Correct | 3 ms | 536 KB | Output is correct |
6 | Correct | 3 ms | 540 KB | Output is correct |
7 | Correct | 3 ms | 680 KB | Output is correct |
8 | Correct | 7 ms | 680 KB | Output is correct |
9 | Correct | 3 ms | 680 KB | Output is correct |
10 | Correct | 7 ms | 680 KB | Output is correct |
11 | Correct | 2 ms | 680 KB | Output is correct |
12 | Correct | 3 ms | 684 KB | Output is correct |
13 | Correct | 6 ms | 684 KB | Output is correct |
14 | Correct | 2 ms | 720 KB | Output is correct |
15 | Correct | 2 ms | 740 KB | Output is correct |
16 | Correct | 2 ms | 764 KB | Output is correct |
17 | Correct | 4 ms | 788 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 420 KB | Output is correct |
4 | Correct | 3 ms | 420 KB | Output is correct |
5 | Correct | 3 ms | 536 KB | Output is correct |
6 | Correct | 3 ms | 540 KB | Output is correct |
7 | Correct | 3 ms | 680 KB | Output is correct |
8 | Correct | 7 ms | 680 KB | Output is correct |
9 | Correct | 3 ms | 680 KB | Output is correct |
10 | Correct | 7 ms | 680 KB | Output is correct |
11 | Correct | 2 ms | 680 KB | Output is correct |
12 | Correct | 3 ms | 684 KB | Output is correct |
13 | Correct | 6 ms | 684 KB | Output is correct |
14 | Correct | 2 ms | 720 KB | Output is correct |
15 | Correct | 2 ms | 740 KB | Output is correct |
16 | Correct | 2 ms | 764 KB | Output is correct |
17 | Correct | 4 ms | 788 KB | Output is correct |
18 | Correct | 4 ms | 788 KB | Output is correct |
19 | Correct | 97 ms | 788 KB | Output is correct |
20 | Correct | 27 ms | 788 KB | Output is correct |
21 | Correct | 1498 ms | 788 KB | Output is correct |
22 | Correct | 897 ms | 788 KB | Output is correct |
23 | Correct | 146 ms | 796 KB | Output is correct |
24 | Correct | 1744 ms | 800 KB | Output is correct |
25 | Correct | 5 ms | 816 KB | Output is correct |
26 | Correct | 18 ms | 816 KB | Output is correct |
27 | Correct | 910 ms | 816 KB | Output is correct |
28 | Correct | 34 ms | 816 KB | Output is correct |
29 | Correct | 31 ms | 816 KB | Output is correct |
30 | Correct | 33 ms | 816 KB | Output is correct |
31 | Correct | 264 ms | 840 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 420 KB | Output is correct |
4 | Correct | 3 ms | 420 KB | Output is correct |
5 | Correct | 3 ms | 536 KB | Output is correct |
6 | Correct | 3 ms | 540 KB | Output is correct |
7 | Correct | 3 ms | 680 KB | Output is correct |
8 | Correct | 7 ms | 680 KB | Output is correct |
9 | Correct | 3 ms | 680 KB | Output is correct |
10 | Correct | 7 ms | 680 KB | Output is correct |
11 | Correct | 2 ms | 680 KB | Output is correct |
12 | Correct | 3 ms | 684 KB | Output is correct |
13 | Correct | 6 ms | 684 KB | Output is correct |
14 | Correct | 2 ms | 720 KB | Output is correct |
15 | Correct | 2 ms | 740 KB | Output is correct |
16 | Correct | 2 ms | 764 KB | Output is correct |
17 | Correct | 4 ms | 788 KB | Output is correct |
18 | Correct | 4 ms | 788 KB | Output is correct |
19 | Correct | 97 ms | 788 KB | Output is correct |
20 | Correct | 27 ms | 788 KB | Output is correct |
21 | Correct | 1498 ms | 788 KB | Output is correct |
22 | Correct | 897 ms | 788 KB | Output is correct |
23 | Correct | 146 ms | 796 KB | Output is correct |
24 | Correct | 1744 ms | 800 KB | Output is correct |
25 | Correct | 5 ms | 816 KB | Output is correct |
26 | Correct | 18 ms | 816 KB | Output is correct |
27 | Correct | 910 ms | 816 KB | Output is correct |
28 | Correct | 34 ms | 816 KB | Output is correct |
29 | Correct | 31 ms | 816 KB | Output is correct |
30 | Correct | 33 ms | 816 KB | Output is correct |
31 | Correct | 264 ms | 840 KB | Output is correct |
32 | Correct | 190 ms | 844 KB | Output is correct |
33 | Correct | 62 ms | 844 KB | Output is correct |
34 | Execution timed out | 5090 ms | 844 KB | Time limit exceeded |
35 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 420 KB | Output is correct |
4 | Correct | 3 ms | 420 KB | Output is correct |
5 | Correct | 3 ms | 536 KB | Output is correct |
6 | Correct | 3 ms | 540 KB | Output is correct |
7 | Correct | 3 ms | 680 KB | Output is correct |
8 | Correct | 7 ms | 680 KB | Output is correct |
9 | Correct | 3 ms | 680 KB | Output is correct |
10 | Correct | 7 ms | 680 KB | Output is correct |
11 | Correct | 2 ms | 680 KB | Output is correct |
12 | Correct | 3 ms | 684 KB | Output is correct |
13 | Correct | 6 ms | 684 KB | Output is correct |
14 | Correct | 2 ms | 720 KB | Output is correct |
15 | Correct | 2 ms | 740 KB | Output is correct |
16 | Correct | 2 ms | 764 KB | Output is correct |
17 | Correct | 4 ms | 788 KB | Output is correct |
18 | Correct | 4 ms | 788 KB | Output is correct |
19 | Correct | 97 ms | 788 KB | Output is correct |
20 | Correct | 27 ms | 788 KB | Output is correct |
21 | Correct | 1498 ms | 788 KB | Output is correct |
22 | Correct | 897 ms | 788 KB | Output is correct |
23 | Correct | 146 ms | 796 KB | Output is correct |
24 | Correct | 1744 ms | 800 KB | Output is correct |
25 | Correct | 5 ms | 816 KB | Output is correct |
26 | Correct | 18 ms | 816 KB | Output is correct |
27 | Correct | 910 ms | 816 KB | Output is correct |
28 | Correct | 34 ms | 816 KB | Output is correct |
29 | Correct | 31 ms | 816 KB | Output is correct |
30 | Correct | 33 ms | 816 KB | Output is correct |
31 | Correct | 264 ms | 840 KB | Output is correct |
32 | Correct | 190 ms | 844 KB | Output is correct |
33 | Correct | 62 ms | 844 KB | Output is correct |
34 | Execution timed out | 5090 ms | 844 KB | Time limit exceeded |
35 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 420 KB | Output is correct |
4 | Correct | 3 ms | 420 KB | Output is correct |
5 | Correct | 3 ms | 536 KB | Output is correct |
6 | Correct | 3 ms | 540 KB | Output is correct |
7 | Correct | 3 ms | 680 KB | Output is correct |
8 | Correct | 7 ms | 680 KB | Output is correct |
9 | Correct | 3 ms | 680 KB | Output is correct |
10 | Correct | 7 ms | 680 KB | Output is correct |
11 | Correct | 2 ms | 680 KB | Output is correct |
12 | Correct | 3 ms | 684 KB | Output is correct |
13 | Correct | 6 ms | 684 KB | Output is correct |
14 | Correct | 2 ms | 720 KB | Output is correct |
15 | Correct | 2 ms | 740 KB | Output is correct |
16 | Correct | 2 ms | 764 KB | Output is correct |
17 | Correct | 4 ms | 788 KB | Output is correct |
18 | Correct | 4 ms | 788 KB | Output is correct |
19 | Correct | 97 ms | 788 KB | Output is correct |
20 | Correct | 27 ms | 788 KB | Output is correct |
21 | Correct | 1498 ms | 788 KB | Output is correct |
22 | Correct | 897 ms | 788 KB | Output is correct |
23 | Correct | 146 ms | 796 KB | Output is correct |
24 | Correct | 1744 ms | 800 KB | Output is correct |
25 | Correct | 5 ms | 816 KB | Output is correct |
26 | Correct | 18 ms | 816 KB | Output is correct |
27 | Correct | 910 ms | 816 KB | Output is correct |
28 | Correct | 34 ms | 816 KB | Output is correct |
29 | Correct | 31 ms | 816 KB | Output is correct |
30 | Correct | 33 ms | 816 KB | Output is correct |
31 | Correct | 264 ms | 840 KB | Output is correct |
32 | Correct | 190 ms | 844 KB | Output is correct |
33 | Correct | 62 ms | 844 KB | Output is correct |
34 | Execution timed out | 5090 ms | 844 KB | Time limit exceeded |
35 | Halted | 0 ms | 0 KB | - |