結果
| 問題 |
No.1367 文字列門松
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-06-24 16:42:54 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 848 bytes |
| コンパイル時間 | 2,392 ms |
| コンパイル使用メモリ | 201,124 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-24 16:42:58 |
| 合計ジャッジ時間 | 3,467 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
ソースコード
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
#define rep(i, n) for(int i =0; i < (n); i++)
using ll = long long int;
int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen("input.txt", "r", stdin);
string s; cin >> s;
string t = "kadomatsu";
if (s == t) {
cout << "Yes" << endl;
return 0;
} else if (s.size() >= t.size()) {
cout << "No" << endl;
return 0;
}
vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1, 0));
for (int i = 1; i <= s.size(); i++) {
for (int j = 1; j <= t.size(); j++) {
if (s[i-1] == t[j-1]) {
dp[i][j] = dp[i-1][j-1] + 1;
} else {
dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
}
}
}
if (dp[s.size()][t.size()] == s.size()) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
return 0;
}