제출 #133473

#제출 시각아이디문제언어결과실행 시간메모리
133473dualitySecurity Gate (JOI18_security_gate)C++11
30 / 100
432 ms476 KiB
#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;
}

컴파일 시 표준 에러 (stderr) 메시지

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...