답안 #814479

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
814479 2023-08-08T07:49:49 Z 이성호(#10121) Security Gate (JOI18_security_gate) C++17
30 / 100
4430 ms 312 KB
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;

int N, a[105], prf[105];
bitset<201> dp[101][3], valid;
vector<int> pos;

bool check()
{
    //dp[i][j][k]: dp[i][k][j-mn]
    for (int i = 0; i < 101; i++) {
        for (int j = 0; j < 3; j++) {
            dp[i][j].set(0);
        }
    }
    dp[0][0][100] = 1;
    for (int i = 1; i <= N; i++) {
        if (a[i] == 1) {
            dp[i][0] = dp[i-1][0] << 1;
            dp[i][1] = (dp[i-1][0] | dp[i-1][1]) >> 1;
            dp[i][2] = (dp[i-1][1] | dp[i-1][2]) << 1;
        }
        else {
            dp[i][0] = dp[i-1][0] >> 1;
            dp[i][1] = (dp[i-1][0] | dp[i-1][1]) << 1;
            dp[i][2] = (dp[i-1][1] | dp[i-1][2]) >> 1;
        }
        for (int k = 0; k < 3; k++) dp[i][k] &= valid;
    }
    return dp[N][0][100] | dp[N][1][100] | dp[N][2][100];
}

int main()
{
    cin >> N;
    for (int i = 100; i <= 200; i++) valid[i] = 1;
    for (int i = 1; i <= N; i++) {
        char c; scanf(" %c", &c);
        if (c == 'x') pos.push_back(i);
        else a[i] = c == '(' ? 1 : -1;
    }
    int ans = 0;
    for (int t = 0; t < (1 << pos.size()); t++) {
        for (int j = 0; j < (int)pos.size(); j++) {
            a[pos[j]] = 2 * (t >> j & 1) - 1;
        }
        ans += check();
    }
    cout << ans << '\n';
    return 0;
}

Compilation message

securitygate.cpp: In function 'int main()':
securitygate.cpp:40:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |         char c; scanf(" %c", &c);
      |                 ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 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 304 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 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 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 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 304 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 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 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 2 ms 212 KB Output is correct
20 Correct 6 ms 212 KB Output is correct
21 Correct 16 ms 288 KB Output is correct
22 Correct 18 ms 212 KB Output is correct
23 Correct 3 ms 212 KB Output is correct
24 Correct 18 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 3 ms 212 KB Output is correct
27 Correct 15 ms 312 KB Output is correct
28 Correct 5 ms 212 KB Output is correct
29 Correct 3 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 18 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 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 304 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 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 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 2 ms 212 KB Output is correct
20 Correct 6 ms 212 KB Output is correct
21 Correct 16 ms 288 KB Output is correct
22 Correct 18 ms 212 KB Output is correct
23 Correct 3 ms 212 KB Output is correct
24 Correct 18 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 3 ms 212 KB Output is correct
27 Correct 15 ms 312 KB Output is correct
28 Correct 5 ms 212 KB Output is correct
29 Correct 3 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 18 ms 212 KB Output is correct
32 Correct 59 ms 292 KB Output is correct
33 Correct 16 ms 312 KB Output is correct
34 Correct 1615 ms 292 KB Output is correct
35 Correct 51 ms 292 KB Output is correct
36 Correct 276 ms 296 KB Output is correct
37 Correct 1107 ms 296 KB Output is correct
38 Correct 4430 ms 292 KB Output is correct
39 Correct 51 ms 288 KB Output is correct
40 Correct 3819 ms 288 KB Output is correct
41 Correct 3654 ms 292 KB Output is correct
42 Correct 4252 ms 292 KB Output is correct
43 Correct 2206 ms 292 KB Output is correct
44 Correct 277 ms 292 KB Output is correct
45 Correct 4424 ms 300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 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 304 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 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 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 2 ms 212 KB Output is correct
20 Correct 6 ms 212 KB Output is correct
21 Correct 16 ms 288 KB Output is correct
22 Correct 18 ms 212 KB Output is correct
23 Correct 3 ms 212 KB Output is correct
24 Correct 18 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 3 ms 212 KB Output is correct
27 Correct 15 ms 312 KB Output is correct
28 Correct 5 ms 212 KB Output is correct
29 Correct 3 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 18 ms 212 KB Output is correct
32 Correct 59 ms 292 KB Output is correct
33 Correct 16 ms 312 KB Output is correct
34 Correct 1615 ms 292 KB Output is correct
35 Correct 51 ms 292 KB Output is correct
36 Correct 276 ms 296 KB Output is correct
37 Correct 1107 ms 296 KB Output is correct
38 Correct 4430 ms 292 KB Output is correct
39 Correct 51 ms 288 KB Output is correct
40 Correct 3819 ms 288 KB Output is correct
41 Correct 3654 ms 292 KB Output is correct
42 Correct 4252 ms 292 KB Output is correct
43 Correct 2206 ms 292 KB Output is correct
44 Correct 277 ms 292 KB Output is correct
45 Correct 4424 ms 300 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Incorrect 0 ms 212 KB Output isn't correct
50 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 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 304 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 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 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 2 ms 212 KB Output is correct
20 Correct 6 ms 212 KB Output is correct
21 Correct 16 ms 288 KB Output is correct
22 Correct 18 ms 212 KB Output is correct
23 Correct 3 ms 212 KB Output is correct
24 Correct 18 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 3 ms 212 KB Output is correct
27 Correct 15 ms 312 KB Output is correct
28 Correct 5 ms 212 KB Output is correct
29 Correct 3 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 18 ms 212 KB Output is correct
32 Correct 59 ms 292 KB Output is correct
33 Correct 16 ms 312 KB Output is correct
34 Correct 1615 ms 292 KB Output is correct
35 Correct 51 ms 292 KB Output is correct
36 Correct 276 ms 296 KB Output is correct
37 Correct 1107 ms 296 KB Output is correct
38 Correct 4430 ms 292 KB Output is correct
39 Correct 51 ms 288 KB Output is correct
40 Correct 3819 ms 288 KB Output is correct
41 Correct 3654 ms 292 KB Output is correct
42 Correct 4252 ms 292 KB Output is correct
43 Correct 2206 ms 292 KB Output is correct
44 Correct 277 ms 292 KB Output is correct
45 Correct 4424 ms 300 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Incorrect 0 ms 212 KB Output isn't correct
50 Halted 0 ms 0 KB -