結果
| 問題 |
No.2373 wa, wo, n
|
| コンテスト | |
| ユーザー |
eve__fuyuki
|
| 提出日時 | 2024-04-15 13:14:19 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 824 bytes |
| コンパイル時間 | 1,999 ms |
| コンパイル使用メモリ | 197,400 KB |
| 最終ジャッジ日時 | 2025-02-21 02:09:53 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 WA * 13 |
ソースコード
#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') {
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;
}
eve__fuyuki