結果
問題 | No.2373 wa, wo, n |
ユーザー |
![]() |
提出日時 | 2023-07-07 21:30:59 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 20 ms / 2,000 ms |
コード長 | 723 bytes |
コンパイル時間 | 1,566 ms |
コンパイル使用メモリ | 169,992 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-21 17:13:22 |
合計ジャッジ時間 | 2,767 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 39 |
ソースコード
#include <bits/stdc++.h>using namespace std;bool match(string S, string T){int N = S.size();for (int i = 0; i < N; i++){if (S[i] != '?' && S[i] != T[i]){return false;}}return true;}int main(){int N;cin >> N;string S;cin >> S;vector<bool> dp(N + 1, false);dp[0] = true;for (int i = 0; i < N; i++){if (dp[i]){if (match(S.substr(i, 1), "n")){dp[i + 1] = true;}if (i < N - 1){if (match(S.substr(i, 2), "wa")){dp[i + 2] = true;}if (match(S.substr(i, 2), "wo")){dp[i + 2] = true;}}}}if (dp[N]){cout << "Yes" << endl;} else {cout << "No" << endl;}}