提出 #24497062
ソースコード 拡げる
// {{{
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using vi = vector<int>;
using pii = pair<int, int>;
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
#define debug(x...)
#define debug_arr(x...)
#ifdef LOCAL
#include "prettyprint.hpp"
#endif
// }}}
const int mod = 1e9 + 7;
const int N = 1e5 + 10;
int f(char ch)
{
if (ch == 'c') return 1;
if (ch == 'h') return 2;
if (ch == 'o') return 3;
if (ch == 'k') return 4;
if (ch == 'u') return 5;
if (ch == 'd') return 6;
if (ch == 'a') return 7;
if (ch == 'i') return 8;
return 0;
}
char s[N];
LL dp[N][9];
int main()
{
#ifdef LOCAL
freopen("in", "r", stdin);
// freopen("out", "w", stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(0);
clr(dp, 0);
dp[0][0] = 1;
while (~scanf("%s", s + 1))
{
int n = strlen(s + 1);
for (int i = 0; i < n; i++)
{
int ch = f(s[i + 1]);
for (int j = 0; j <= 8; j++)
{
if (dp[i][j] == 0) continue;
dp[i + 1][j] += dp[i][j];
dp[i + 1][j] %= mod;
}
if (ch >= 1)
{
dp[i + 1][ch] += dp[i][ch - 1];
dp[i + 1][ch] %= mod;
}
}
LL ans = dp[n][8];
cout << ans << endl;
}
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | C - chokudai |
| ユーザ | mickeyandkaka |
| 言語 | C++ (GCC 9.2.1) |
| 得点 | 300 |
| コード長 | 1511 Byte |
| 結果 | AC |
| 実行時間 | 22 ms |
| メモリ | 10824 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 300 / 300 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | example0.txt, example1.txt, example2.txt |
| All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, example0.txt, example1.txt, example2.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 000.txt | AC | 13 ms | 10728 KiB |
| 001.txt | AC | 8 ms | 10748 KiB |
| 002.txt | AC | 7 ms | 10684 KiB |
| 003.txt | AC | 10 ms | 10716 KiB |
| 004.txt | AC | 14 ms | 10704 KiB |
| 005.txt | AC | 8 ms | 10684 KiB |
| 006.txt | AC | 7 ms | 10680 KiB |
| 007.txt | AC | 10 ms | 10728 KiB |
| 008.txt | AC | 12 ms | 10824 KiB |
| 009.txt | AC | 15 ms | 10796 KiB |
| 010.txt | AC | 14 ms | 10724 KiB |
| 011.txt | AC | 15 ms | 10800 KiB |
| 012.txt | AC | 14 ms | 10808 KiB |
| 013.txt | AC | 22 ms | 10796 KiB |
| 014.txt | AC | 12 ms | 10804 KiB |
| 015.txt | AC | 11 ms | 10796 KiB |
| example0.txt | AC | 7 ms | 10616 KiB |
| example1.txt | AC | 10 ms | 10700 KiB |
| example2.txt | AC | 12 ms | 10708 KiB |