結果

問題 No.1367 文字列門松
ユーザー noritakenoritake
提出日時 2021-01-29 21:56:26
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,611 bytes
コンパイル時間 1,714 ms
コンパイル使用メモリ 168,828 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 15:20:07
合計ジャッジ時間 2,592 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,384 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// #include <atcoder/all> // NOTE: AtCoderライブラリ
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl;
#define dbg3(x, y, z) cerr << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;
#define nl() cout << "========================================" << endl;
using namespace std;
// using namespace atcoder; // NOTE: AtCoderライブラリ
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<vector<long long>> vvl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
const long long LINF = 1001002003004005006ll;
const int INF = 1001001001;
template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }
#define yn { puts("Yes"); } else{ puts("No"); } // 使い方: if (条件) yn; 

int main() {
    string S; cin >> S;
    string T = "kadomatsu";
    int N = S.size(), M = T.size();

    vvi dp(N + 1, vi(M + 1, 0));
    rep(i, N) {
        rep(j, M) {
            if (S[i] == T[j]) {
                chmax(dp[i + 1][j + 1], dp[i][j] + 1);
            } else {
                chmax(dp[i + 1][j + 1], dp[i + 1][j]);
                chmax(dp[i + 1][j + 1], dp[i][j + 1]);
            }
        }
    }

    if (dp[N][M] == N) yn;
}
0