結果
| 問題 | No.2373 wa, wo, n | 
| コンテスト | |
| ユーザー |  eve__fuyuki | 
| 提出日時 | 2024-04-15 13:15:03 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 13 ms / 2,000 ms | 
| コード長 | 839 bytes | 
| コンパイル時間 | 2,278 ms | 
| コンパイル使用メモリ | 196,932 KB | 
| 最終ジャッジ日時 | 2025-02-21 02:10:02 | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 39 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}
int main() {
    fast_io();
    int n;
    string s;
    cin >> n >> s;
    auto match = [](string s, string t) {
        for (int i = 0; i < s.size(); i++) {
            if (s[i] != t[i] && s[i] != '?' && t[i] != '?') {
                return false;
            }
        }
        return true;
    };
    vector<bool> dp(n + 1);
    dp[0] = true;
    for (int i = 0; i < n; i++) {
        if (!dp[i]) {
            continue;
        }
        if (s[i] == 'n' || s[i] == '?') {
            dp[i + 1] = true;
        }
        if (i < n - 1 &&
            (match(s.substr(i, 2), "wa") || match(s.substr(i, 2), "wo"))) {
            dp[i + 2] = true;
        }
    }
    cout << (dp[n] ? "Yes" : "No") << endl;
}
            
            
            
        