# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
47763 | 2018-05-07T05:51:46 Z | daniel_02 | Security Gate (JOI18_security_gate) | C++17 | 5000 ms | 860 KB |
#include <bits/stdc++.h> #define pb push_back using namespace std; const int N = 305; int ans, pr[N]; vector<int>dam; bool ch(string s) { int sm = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '(') sm ++; else sm--; if (sm < 0) { return 0; } } if (sm == 0)return 1; return 0; } bool check(string s) { string s1; s1 = s; if (ch(s)) { return 1; } for (int i = 0; i < s.size(); i++) { for (int j = i; j < s.size(); j++) { if (s1[j] == ')') s1[j] = '('; else s1[j] = ')'; if (ch(s1)) { return 1; } } s1 = s; } return 0; } main() { int n; cin >> n; string s, s1; cin >> s; s1 = s; for (int i = 0; i < s.size(); i++) { if (s[i] == 'x') { dam.pb(i); } } for (int msk = 0; msk < (1 << int(dam.size())); msk ++) { for (int i = 0; i < dam.size(); i++) { if (msk & (1 << i)) s1[dam[i]] = '('; else s1[dam[i]] = ')'; } if (check(s1)) { ans++; } } cout << ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 548 KB | Output is correct |
4 | Correct | 2 ms | 548 KB | Output is correct |
5 | Correct | 2 ms | 548 KB | Output is correct |
6 | Correct | 3 ms | 548 KB | Output is correct |
7 | Correct | 2 ms | 548 KB | Output is correct |
8 | Correct | 4 ms | 676 KB | Output is correct |
9 | Correct | 2 ms | 676 KB | Output is correct |
10 | Correct | 6 ms | 676 KB | Output is correct |
11 | Correct | 2 ms | 676 KB | Output is correct |
12 | Correct | 2 ms | 676 KB | Output is correct |
13 | Correct | 5 ms | 676 KB | Output is correct |
14 | Correct | 2 ms | 676 KB | Output is correct |
15 | Correct | 2 ms | 676 KB | Output is correct |
16 | Correct | 2 ms | 676 KB | Output is correct |
17 | Correct | 3 ms | 676 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 548 KB | Output is correct |
4 | Correct | 2 ms | 548 KB | Output is correct |
5 | Correct | 2 ms | 548 KB | Output is correct |
6 | Correct | 3 ms | 548 KB | Output is correct |
7 | Correct | 2 ms | 548 KB | Output is correct |
8 | Correct | 4 ms | 676 KB | Output is correct |
9 | Correct | 2 ms | 676 KB | Output is correct |
10 | Correct | 6 ms | 676 KB | Output is correct |
11 | Correct | 2 ms | 676 KB | Output is correct |
12 | Correct | 2 ms | 676 KB | Output is correct |
13 | Correct | 5 ms | 676 KB | Output is correct |
14 | Correct | 2 ms | 676 KB | Output is correct |
15 | Correct | 2 ms | 676 KB | Output is correct |
16 | Correct | 2 ms | 676 KB | Output is correct |
17 | Correct | 3 ms | 676 KB | Output is correct |
18 | Correct | 5 ms | 676 KB | Output is correct |
19 | Correct | 64 ms | 748 KB | Output is correct |
20 | Correct | 54 ms | 784 KB | Output is correct |
21 | Correct | 1192 ms | 788 KB | Output is correct |
22 | Correct | 888 ms | 804 KB | Output is correct |
23 | Correct | 139 ms | 804 KB | Output is correct |
24 | Correct | 1415 ms | 812 KB | Output is correct |
25 | Correct | 3 ms | 824 KB | Output is correct |
26 | Correct | 19 ms | 824 KB | Output is correct |
27 | Correct | 683 ms | 840 KB | Output is correct |
28 | Correct | 44 ms | 840 KB | Output is correct |
29 | Correct | 12 ms | 840 KB | Output is correct |
30 | Correct | 19 ms | 840 KB | Output is correct |
31 | Correct | 180 ms | 844 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 548 KB | Output is correct |
4 | Correct | 2 ms | 548 KB | Output is correct |
5 | Correct | 2 ms | 548 KB | Output is correct |
6 | Correct | 3 ms | 548 KB | Output is correct |
7 | Correct | 2 ms | 548 KB | Output is correct |
8 | Correct | 4 ms | 676 KB | Output is correct |
9 | Correct | 2 ms | 676 KB | Output is correct |
10 | Correct | 6 ms | 676 KB | Output is correct |
11 | Correct | 2 ms | 676 KB | Output is correct |
12 | Correct | 2 ms | 676 KB | Output is correct |
13 | Correct | 5 ms | 676 KB | Output is correct |
14 | Correct | 2 ms | 676 KB | Output is correct |
15 | Correct | 2 ms | 676 KB | Output is correct |
16 | Correct | 2 ms | 676 KB | Output is correct |
17 | Correct | 3 ms | 676 KB | Output is correct |
18 | Correct | 5 ms | 676 KB | Output is correct |
19 | Correct | 64 ms | 748 KB | Output is correct |
20 | Correct | 54 ms | 784 KB | Output is correct |
21 | Correct | 1192 ms | 788 KB | Output is correct |
22 | Correct | 888 ms | 804 KB | Output is correct |
23 | Correct | 139 ms | 804 KB | Output is correct |
24 | Correct | 1415 ms | 812 KB | Output is correct |
25 | Correct | 3 ms | 824 KB | Output is correct |
26 | Correct | 19 ms | 824 KB | Output is correct |
27 | Correct | 683 ms | 840 KB | Output is correct |
28 | Correct | 44 ms | 840 KB | Output is correct |
29 | Correct | 12 ms | 840 KB | Output is correct |
30 | Correct | 19 ms | 840 KB | Output is correct |
31 | Correct | 180 ms | 844 KB | Output is correct |
32 | Correct | 444 ms | 860 KB | Output is correct |
33 | Correct | 132 ms | 860 KB | Output is correct |
34 | Execution timed out | 5017 ms | 860 KB | Time limit exceeded |
35 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 548 KB | Output is correct |
4 | Correct | 2 ms | 548 KB | Output is correct |
5 | Correct | 2 ms | 548 KB | Output is correct |
6 | Correct | 3 ms | 548 KB | Output is correct |
7 | Correct | 2 ms | 548 KB | Output is correct |
8 | Correct | 4 ms | 676 KB | Output is correct |
9 | Correct | 2 ms | 676 KB | Output is correct |
10 | Correct | 6 ms | 676 KB | Output is correct |
11 | Correct | 2 ms | 676 KB | Output is correct |
12 | Correct | 2 ms | 676 KB | Output is correct |
13 | Correct | 5 ms | 676 KB | Output is correct |
14 | Correct | 2 ms | 676 KB | Output is correct |
15 | Correct | 2 ms | 676 KB | Output is correct |
16 | Correct | 2 ms | 676 KB | Output is correct |
17 | Correct | 3 ms | 676 KB | Output is correct |
18 | Correct | 5 ms | 676 KB | Output is correct |
19 | Correct | 64 ms | 748 KB | Output is correct |
20 | Correct | 54 ms | 784 KB | Output is correct |
21 | Correct | 1192 ms | 788 KB | Output is correct |
22 | Correct | 888 ms | 804 KB | Output is correct |
23 | Correct | 139 ms | 804 KB | Output is correct |
24 | Correct | 1415 ms | 812 KB | Output is correct |
25 | Correct | 3 ms | 824 KB | Output is correct |
26 | Correct | 19 ms | 824 KB | Output is correct |
27 | Correct | 683 ms | 840 KB | Output is correct |
28 | Correct | 44 ms | 840 KB | Output is correct |
29 | Correct | 12 ms | 840 KB | Output is correct |
30 | Correct | 19 ms | 840 KB | Output is correct |
31 | Correct | 180 ms | 844 KB | Output is correct |
32 | Correct | 444 ms | 860 KB | Output is correct |
33 | Correct | 132 ms | 860 KB | Output is correct |
34 | Execution timed out | 5017 ms | 860 KB | Time limit exceeded |
35 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 548 KB | Output is correct |
4 | Correct | 2 ms | 548 KB | Output is correct |
5 | Correct | 2 ms | 548 KB | Output is correct |
6 | Correct | 3 ms | 548 KB | Output is correct |
7 | Correct | 2 ms | 548 KB | Output is correct |
8 | Correct | 4 ms | 676 KB | Output is correct |
9 | Correct | 2 ms | 676 KB | Output is correct |
10 | Correct | 6 ms | 676 KB | Output is correct |
11 | Correct | 2 ms | 676 KB | Output is correct |
12 | Correct | 2 ms | 676 KB | Output is correct |
13 | Correct | 5 ms | 676 KB | Output is correct |
14 | Correct | 2 ms | 676 KB | Output is correct |
15 | Correct | 2 ms | 676 KB | Output is correct |
16 | Correct | 2 ms | 676 KB | Output is correct |
17 | Correct | 3 ms | 676 KB | Output is correct |
18 | Correct | 5 ms | 676 KB | Output is correct |
19 | Correct | 64 ms | 748 KB | Output is correct |
20 | Correct | 54 ms | 784 KB | Output is correct |
21 | Correct | 1192 ms | 788 KB | Output is correct |
22 | Correct | 888 ms | 804 KB | Output is correct |
23 | Correct | 139 ms | 804 KB | Output is correct |
24 | Correct | 1415 ms | 812 KB | Output is correct |
25 | Correct | 3 ms | 824 KB | Output is correct |
26 | Correct | 19 ms | 824 KB | Output is correct |
27 | Correct | 683 ms | 840 KB | Output is correct |
28 | Correct | 44 ms | 840 KB | Output is correct |
29 | Correct | 12 ms | 840 KB | Output is correct |
30 | Correct | 19 ms | 840 KB | Output is correct |
31 | Correct | 180 ms | 844 KB | Output is correct |
32 | Correct | 444 ms | 860 KB | Output is correct |
33 | Correct | 132 ms | 860 KB | Output is correct |
34 | Execution timed out | 5017 ms | 860 KB | Time limit exceeded |
35 | Halted | 0 ms | 0 KB | - |