結果
問題 | No.2373 wa, wo, n |
ユーザー |
![]() |
提出日時 | 2024-04-15 13:15:03 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 839 bytes |
コンパイル時間 | 2,304 ms |
コンパイル使用メモリ | 204,376 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-05 09:41:34 |
合計ジャッジ時間 | 3,704 ms |
ジャッジサーバーID (参考情報) |
judge2 / 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; }