Submission #133473

# Submission time Handle Problem Language Result Execution time Memory
133473 2019-07-20T20:59:09 Z duality Security Gate (JOI18_security_gate) C++11
30 / 100
432 ms 476 KB
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef long long int LLI;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
#define MOD 1000000007

char S[300];
unsigned long long int dp[301][3];
int main() {
    int i;
    int N;
    scanf("%d",&N);
    for (i = 0; i < N; i++) scanf(" %c",&S[i]);
    if (N & 1) {
        printf("0\n");
        return 0;
    }

    int j;
    vi v;
    for (i = 0; i < N; i++) {
        if (S[i] == 'x') v.pb(i);
    }
    int ans = 0;
    for (i = 0; i < (1 << v.size()); i++) {
        for (j = 0; j < v.size(); j++) {
            if (i & (1 << j)) S[v[j]] = '(';
            else S[v[j]] = ')';
        }
        dp[0][0] = 1,dp[0][1] = dp[0][2] = 0;
        for (j = 0; j < N; j++) {
            if (S[j] == '(') {
                dp[j+1][0] = dp[j][0] << 1;
                dp[j+1][1] = (dp[j][0] | dp[j][1]) >> 1;
                dp[j+1][2] = (dp[j][1] | dp[j][2]) << 1;
            }
            else {
                dp[j+1][0] = dp[j][0] >> 1;
                dp[j+1][1] = (dp[j][0] | dp[j][1]) << 1;
                dp[j+1][2] = (dp[j][1] | dp[j][2]) >> 1;
            }
        }
        if ((dp[N][0] | dp[N][1] | dp[N][2]) & 1) ans++;
    }
    printf("%d\n",ans);

    return 0;
}

Compilation message

securitygate.cpp: In function 'int main()':
securitygate.cpp:30:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (j = 0; j < v.size(); j++) {
                     ~~^~~~~~~~~~
securitygate.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&N);
     ~~~~~^~~~~~~~~
securitygate.cpp:17:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (i = 0; i < N; i++) scanf(" %c",&S[i]);
                             ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 3 ms 396 KB Output is correct
21 Correct 3 ms 348 KB Output is correct
22 Correct 3 ms 296 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 2 ms 256 KB Output is correct
31 Correct 4 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 3 ms 396 KB Output is correct
21 Correct 3 ms 348 KB Output is correct
22 Correct 3 ms 296 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 2 ms 256 KB Output is correct
31 Correct 4 ms 376 KB Output is correct
32 Correct 14 ms 376 KB Output is correct
33 Correct 5 ms 376 KB Output is correct
34 Correct 247 ms 376 KB Output is correct
35 Correct 13 ms 376 KB Output is correct
36 Correct 28 ms 380 KB Output is correct
37 Correct 106 ms 476 KB Output is correct
38 Correct 432 ms 256 KB Output is correct
39 Correct 14 ms 376 KB Output is correct
40 Correct 397 ms 376 KB Output is correct
41 Correct 379 ms 376 KB Output is correct
42 Correct 432 ms 360 KB Output is correct
43 Correct 213 ms 252 KB Output is correct
44 Correct 29 ms 360 KB Output is correct
45 Correct 428 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 3 ms 396 KB Output is correct
21 Correct 3 ms 348 KB Output is correct
22 Correct 3 ms 296 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 2 ms 256 KB Output is correct
31 Correct 4 ms 376 KB Output is correct
32 Correct 14 ms 376 KB Output is correct
33 Correct 5 ms 376 KB Output is correct
34 Correct 247 ms 376 KB Output is correct
35 Correct 13 ms 376 KB Output is correct
36 Correct 28 ms 380 KB Output is correct
37 Correct 106 ms 476 KB Output is correct
38 Correct 432 ms 256 KB Output is correct
39 Correct 14 ms 376 KB Output is correct
40 Correct 397 ms 376 KB Output is correct
41 Correct 379 ms 376 KB Output is correct
42 Correct 432 ms 360 KB Output is correct
43 Correct 213 ms 252 KB Output is correct
44 Correct 29 ms 360 KB Output is correct
45 Correct 428 ms 376 KB Output is correct
46 Correct 2 ms 256 KB Output is correct
47 Correct 2 ms 252 KB Output is correct
48 Correct 2 ms 380 KB Output is correct
49 Incorrect 2 ms 252 KB Output isn't correct
50 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 3 ms 396 KB Output is correct
21 Correct 3 ms 348 KB Output is correct
22 Correct 3 ms 296 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 2 ms 256 KB Output is correct
31 Correct 4 ms 376 KB Output is correct
32 Correct 14 ms 376 KB Output is correct
33 Correct 5 ms 376 KB Output is correct
34 Correct 247 ms 376 KB Output is correct
35 Correct 13 ms 376 KB Output is correct
36 Correct 28 ms 380 KB Output is correct
37 Correct 106 ms 476 KB Output is correct
38 Correct 432 ms 256 KB Output is correct
39 Correct 14 ms 376 KB Output is correct
40 Correct 397 ms 376 KB Output is correct
41 Correct 379 ms 376 KB Output is correct
42 Correct 432 ms 360 KB Output is correct
43 Correct 213 ms 252 KB Output is correct
44 Correct 29 ms 360 KB Output is correct
45 Correct 428 ms 376 KB Output is correct
46 Correct 2 ms 256 KB Output is correct
47 Correct 2 ms 252 KB Output is correct
48 Correct 2 ms 380 KB Output is correct
49 Incorrect 2 ms 252 KB Output isn't correct
50 Halted 0 ms 0 KB -