結果
| 問題 |
No.1367 文字列門松
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-06-24 16:37:33 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 844 bytes |
| コンパイル時間 | 2,637 ms |
| コンパイル使用メモリ | 201,008 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-24 16:37:37 |
| 合計ジャッジ時間 | 3,210 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 = 0; i < s.size(); i++) {
for (int j = 0; j < t.size(); j++) {
if (s[i] == t[j]) {
dp[i+1][j+1] = dp[i][j] + 1;
} else {
dp[i+1][j+1] = 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;
}