結果

問題 No.2373 wa, wo, n
コンテスト
ユーザー V_Melville
提出日時 2023-07-07 21:54:12
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,067 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,354 ms
コンパイル使用メモリ 333,928 KB
実行使用メモリ 7,976 KB
最終ジャッジ日時 2026-04-03 05:30:05
合計ジャッジ時間 4,854 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge5_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 25 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    
    string s;
    cin >> s;
    
    for (char c : s) {
        if (c != '?' and c != 'w' and c != 'a' and c != 'o' and c != 'n') {
            puts("No");
            return 0;
        }
    }
    
    if (n == 1) {
        if (s[0] != '?') {
            if (s[0] != 'n') {
                puts("No");
                return 0;
            }
        }
    }
    
    if (s[0] == 'o' or s[0] == 'a') {
        puts("No");
        return 0;
    }
    
    for (int i = 1; i < n; ++i) {
        if (s[i] == 'o') {
            if (s[i-1] != '?') {
                if (s[i] != 'w') {
                    puts("No");
                    return 0;
                }
            }
        }
    }
    
    for (int i = 1; i < n; ++i) {
        if (s[i] == 'a') {
            if (s[i-1] != '?') {
                if (s[i] != 'w') {
                    puts("No");
                    return 0;
                }
            }
        }
    }
    
    puts("Yes");
    
    return 0;
}
0