# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
133473 | duality | Security Gate (JOI18_security_gate) | C++11 | 432 ms | 476 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |