結果
問題 |
No.2373 wa, wo, n
|
ユーザー |
![]() |
提出日時 | 2023-06-24 00:37:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,183 bytes |
コンパイル時間 | 1,999 ms |
コンパイル使用メモリ | 197,520 KB |
最終ジャッジ日時 | 2025-02-15 01:48:22 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 11 TLE * 1 -- * 27 |
ソースコード
// 嘘解法 (TLE) // DFS で全探索 #include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(15); int N; cin >> N; string S; cin >> S; string T = "waon?"; for (auto s : S) { if (T.find(s) == string::npos) { cout << "No" << '\n'; return 0; } } auto match = [&](string s, string p) -> bool { assert(s.size() == p.size()); for (int i = 0; i < (int)s.size(); i++) { if (s[i] == p[i] || s[i] == '?') { continue; } return false; } return true; }; vector<string> patterns = {"wa", "wo", "n"}; // S[0,i) が wawon 文字列になっている auto dfs = [&](auto&& self, int i) -> void { if (i == N) { cout << "Yes" << '\n'; exit(0); } for (auto p : patterns) { int n = p.size(); if (i + n <= N && match(S.substr(i, n), p)) { self(self, i + n); } } }; dfs(dfs, 0); cout << "No" << '\n'; return 0; }