Submission #2329315
Source Code Expand
#include <iostream>
#include <vector>
using namespace std;
const int mod = 1000000007;
typedef long long ll;
int main() {
int N, K, L;
cin >> N >> K >> L;
K--;
vector<vector<ll> > dp(N+1, vector<ll>(1<<(3*K), 0));
dp[0][0] = 1;
for (int i=0; i<N; i++) {
for (int j=0; j<(1<<(3*K)); j++) {
for (int k=0; k<(1<<3); k++) {
if (k == 0) continue;
bool ok = true;
for (int x=0; x<3; x++) {
if (!(k & (1<<x))) continue;
int total = 0;
for (int y=x; y<3*K; y+=3)
if (j & (1<<y)) total++;
if (total >= L) ok = false;
}
if (ok) {
dp[i+1][((j<<3)+k)%(1<<3*K)] += dp[i][j];
dp[i+1][((j<<3)+k)%(1<<3*K)] %= mod;
}
}
}
}
ll total = 0;
for (int i=0; i<(1<<(K*3)); i++) {
total += dp[N][i];
total %= mod;
}
cout << total << endl;
}
Submission Info
| Submission Time | |
|---|---|
| Task | F - 献立表制作 |
| User | suminos |
| Language | C++14 (GCC 5.4.1) |
| Score | 100 |
| Code Size | 929 Byte |
| Status | AC |
| Exec Time | 142 ms |
| Memory | 12416 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 100 / 100 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | s1.txt, s2.txt, s3.txt, s4.txt |
| All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, s1.txt, s2.txt, s3.txt, s4.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01.txt | AC | 1 ms | 256 KiB |
| 02.txt | AC | 2 ms | 256 KiB |
| 03.txt | AC | 1 ms | 256 KiB |
| 04.txt | AC | 6 ms | 640 KiB |
| 05.txt | AC | 2 ms | 256 KiB |
| 06.txt | AC | 4 ms | 512 KiB |
| 07.txt | AC | 1 ms | 256 KiB |
| 08.txt | AC | 1 ms | 256 KiB |
| 09.txt | AC | 1 ms | 256 KiB |
| 10.txt | AC | 2 ms | 256 KiB |
| 11.txt | AC | 2 ms | 384 KiB |
| 12.txt | AC | 11 ms | 1152 KiB |
| 13.txt | AC | 85 ms | 6784 KiB |
| 14.txt | AC | 1 ms | 256 KiB |
| 15.txt | AC | 11 ms | 1024 KiB |
| 16.txt | AC | 1 ms | 256 KiB |
| 17.txt | AC | 3 ms | 384 KiB |
| 18.txt | AC | 1 ms | 256 KiB |
| 19.txt | AC | 111 ms | 10496 KiB |
| 20.txt | AC | 1 ms | 256 KiB |
| 21.txt | AC | 137 ms | 12416 KiB |
| 22.txt | AC | 113 ms | 11392 KiB |
| 23.txt | AC | 122 ms | 10368 KiB |
| 24.txt | AC | 121 ms | 10240 KiB |
| 25.txt | AC | 141 ms | 11008 KiB |
| s1.txt | AC | 1 ms | 256 KiB |
| s2.txt | AC | 1 ms | 256 KiB |
| s3.txt | AC | 142 ms | 12032 KiB |
| s4.txt | AC | 3 ms | 512 KiB |