結果

問題 No.2373 wa, wo, n
ユーザー ks2mks2m
提出日時 2023-07-07 21:37:07
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 723 bytes
コンパイル時間 2,352 ms
コンパイル使用メモリ 74,688 KB
実行使用メモリ 43,496 KB
最終ジャッジ日時 2024-07-21 17:21:37
合計ジャッジ時間 9,874 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 38 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] s = sc.next().toCharArray();
		sc.close();

		for (int i = n - 1; i >= 0; i--) {
			if (s[i] != 'w' && s[i] != 'a' && s[i] != 'o' && s[i] != 'n' && s[i] != '?') {
				System.out.println("No");
				return;
			}
			if (s[i] == 'a' || s[i] == 'o') {
				if (i == 0 || s[i - 1] != 'w' && s[i - 1] != '?') {
					System.out.println("No");
					return;
				}
				s[i - 1] = 'w';
			}
			if (s[i] == 'w' || s[i] == 'n') {
				if (i != 0 && s[i - 1] == 'w') {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
}
0