結果
| 問題 | No.1367 文字列門松 | 
| コンテスト | |
| ユーザー |  maimaicorgi | 
| 提出日時 | 2022-09-28 19:21:45 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 1,966 bytes | 
| コンパイル時間 | 1,380 ms | 
| コンパイル使用メモリ | 138,020 KB | 
| 最終ジャッジ日時 | 2025-02-07 18:02:30 | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 27 | 
ソースコード
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <ios>
#include <iomanip>
#include <queue>
#include <numeric>
#include <map>
#include <set>
#include <sstream>
#include <bitset>
#include <climits>
#include <stack>
#include <regex>
#include <functional>
#include <random>
#ifdef _WIN64
#  include <atcoder/all>
#endif
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#  define __builtin_popcountl __popcnt64
#endif
using namespace std;
#define ll long long
#define rep(i, init, n) for(ll i = init; i < (ll)n; i++)
#define rrep(i, init, n) for(ll i = init; i >= (ll)n; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x.size())
#define Out(x) cout << x << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define Ans cout << ans << endl
#define PI 3.14159265358979
#define MOD 998244353
const int inf32 = INT_MAX / 2;
const ll inf64 = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
// -------------------------------------------------------------------------------------------------
string LCS(string s, string t)
{
	int n = s.length();
	int m = t.length();
	s.insert(s.begin(), ' ');
	t.insert(t.begin(), ' ');
	vector dp(n + 1, vector<int>(m + 1));
	rep(i, 1, n + 1)rep(j, 1, m + 1)
	{
		if (s[i] == t[j]) chmax(dp[i][j], dp[i - 1][j - 1] + 1);
		else chmax(dp[i][j], max(dp[i - 1][j], dp[i][j - 1]));
	}
	int i = n, j = m;
	string lcs;
	while (i > 0 && j > 0)
	{
		if (s[i] == t[j])
		{
			lcs += s[i];
			i--, j--;
		}
		else
		{
			if (dp[i - 1][j] == dp[i][j]) i--;
			else j--;
		}
	}
	reverse(all(lcs));
	return lcs;
}
int main()
{
	string s; cin >> s;
	string lcs = LCS(s, "kadomatsu");
	if (s == lcs) Yes;
	else No;
	return 0;
}
            
            
            
        