結果

問題 No.2373 wa, wo, n
ユーザー poyonpoyon
提出日時 2023-06-24 00:37:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,183 bytes
コンパイル時間 2,507 ms
コンパイル使用メモリ 203,992 KB
実行使用メモリ 25,328 KB
最終ジャッジ日時 2023-09-15 06:55:27
合計ジャッジ時間 5,977 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 25 ms
25,328 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// 嘘解法 (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;
}
0