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>
#define ve vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define si(v) (int)v.size()
#define en '\n'
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e4 + 228;
const int big = 1e9;
int n, m, k, x, f[N][2][2][2][2][2], ans[10];
void setNum(int i, int x){
if (x == 0) f[i][1][1][1][1][0] = 1;
if (x == 1) f[i][1][1][0][1][1] = 1;
if (x == 2) f[i][0][1][1][1][0] = 1;
if (x == 3) f[i][0][1][0][0][1] = 1;
if (x == 4) f[i][1][0][0][1][1] = 1;
if (x == 5) f[i][0][0][1][0][1] = 1;
if (x == 6) f[i][1][1][1][0][0] = 1;
if (x == 7) f[i][0][1][0][1][1] = 1;
if (x == 8) f[i][0][0][1][0][0] = 1;
if (x == 9) f[i][0][0][0][0][1] = 1;
}
bool check2(int d1, int d2, int d3, int d4, int d5, int v1, int v2, int v3, int v4, int v5){
if (d1 == v1 && d2 == v2 && d3 == v3 && d4 == v4 && d5 == v5) return 1;
return 0;
}
int getNum(int d1, int d2, int d3, int d4, int d5){
if (check2(d1, d2, d3, d4, d5, 1, 1, 1, 1, 0)) return 0;
if (check2(d1, d2, d3, d4, d5, 1, 1, 0, 1, 1)) return 1;
if (check2(d1, d2, d3, d4, d5, 0, 1, 1, 1, 0)) return 2;
if (check2(d1, d2, d3, d4, d5, 0, 1, 0, 0, 1)) return 3;
if (check2(d1, d2, d3, d4, d5, 1, 0, 0, 1, 1)) return 4;
if (check2(d1, d2, d3, d4, d5, 0, 0, 1, 0, 1)) return 5;
if (check2(d1, d2, d3, d4, d5, 1, 1, 1, 0, 0)) return 6;
if (check2(d1, d2, d3, d4, d5, 0, 1, 0, 1, 1)) return 7;
if (check2(d1, d2, d3, d4, d5, 0, 0, 1, 0, 0)) return 8;
if (check2(d1, d2, d3, d4, d5, 0, 0, 0, 0, 1)) return 8;
return -1;
}
int main(){
iostream::sync_with_stdio(false); cin.tie(0); ios_base::sync_with_stdio(false); cout.tie(0);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
cin >> m >> n >> k >> x;
setNum(0, x);
for (int i = 0; i < n; i++){
for (int d1 = 0; d1 <= 1; d1++)
for (int d2 = 0; d2 <= 1; d2++)
for (int d3 = 0; d3 <= 1; d3++)
for (int d4 = 0; d4 <= 1; d4++)
for (int d5 = 0; d5 <= 1; d5++){
int cur = f[i][d1][d2][d3][d4][d5];
if (cur == 0) continue;
if (i == k){
if (getNum(d1, d2, d3, d4, d5) == -1) {f[i][d1][d2][d3][d4][d5] = 0;continue;}
}
f[i + 1][d1 ^ 1][d2][d3][d4][d5] += cur;
f[i + 1][d1][d2 ^ 1][d3][d4][d5] += cur;
f[i + 1][d1][d2][d3 ^ 1][d4][d5] += cur;
f[i + 1][d1][d2][d3][d4 ^ 1][d5] += cur;
f[i + 1][d1][d2][d3][d4][d5 ^ 1] += cur;
}
}
for (int d1 = 0; d1 <= 1; d1++)
for (int d2 = 0; d2 <= 1; d2++)
for (int d3 = 0; d3 <= 1; d3++)
for (int d4 = 0; d4 <= 1; d4++)
for (int d5 = 0; d5 <= 1; d5++){
int cur = f[n][d1][d2][d3][d4][d5];
int num = getNum(d1, d2, d3, d4, d5);
if (num == -1) continue;
ans[num] = cur;
}
for (int i = 0; i <= 9; i++){
cout << ans[i] << en;
}
return 0;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |