結果

問題 No.2373 wa, wo, n
ユーザー ks2mks2m
提出日時 2023-07-07 21:38:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 219 ms / 2,000 ms
コード長 799 bytes
コンパイル時間 2,045 ms
コンパイル使用メモリ 74,228 KB
実行使用メモリ 58,872 KB
最終ジャッジ日時 2023-09-28 22:38:57
合計ジャッジ時間 10,514 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,908 KB
testcase_01 AC 121 ms
55,876 KB
testcase_02 AC 120 ms
55,644 KB
testcase_03 AC 122 ms
55,772 KB
testcase_04 AC 121 ms
56,012 KB
testcase_05 AC 125 ms
56,132 KB
testcase_06 AC 120 ms
55,976 KB
testcase_07 AC 118 ms
56,156 KB
testcase_08 AC 118 ms
55,820 KB
testcase_09 AC 117 ms
55,880 KB
testcase_10 AC 117 ms
56,052 KB
testcase_11 AC 117 ms
56,120 KB
testcase_12 AC 120 ms
55,740 KB
testcase_13 AC 121 ms
55,864 KB
testcase_14 AC 211 ms
58,576 KB
testcase_15 AC 144 ms
55,856 KB
testcase_16 AC 212 ms
58,116 KB
testcase_17 AC 183 ms
56,904 KB
testcase_18 AC 136 ms
56,280 KB
testcase_19 AC 174 ms
56,336 KB
testcase_20 AC 195 ms
57,960 KB
testcase_21 AC 182 ms
55,928 KB
testcase_22 AC 191 ms
56,564 KB
testcase_23 AC 200 ms
58,276 KB
testcase_24 AC 121 ms
56,052 KB
testcase_25 AC 121 ms
55,952 KB
testcase_26 AC 123 ms
55,784 KB
testcase_27 AC 120 ms
55,744 KB
testcase_28 AC 125 ms
55,632 KB
testcase_29 AC 123 ms
55,880 KB
testcase_30 AC 121 ms
56,020 KB
testcase_31 AC 123 ms
56,004 KB
testcase_32 AC 219 ms
58,420 KB
testcase_33 AC 197 ms
58,528 KB
testcase_34 AC 217 ms
58,792 KB
testcase_35 AC 200 ms
58,372 KB
testcase_36 AC 212 ms
58,500 KB
testcase_37 AC 210 ms
58,364 KB
testcase_38 AC 211 ms
58,524 KB
testcase_39 AC 214 ms
58,348 KB
testcase_40 AC 215 ms
58,872 KB
testcase_41 AC 214 ms
58,124 KB
testcase_42 AC 214 ms
58,532 KB
権限があれば一括ダウンロードができます

ソースコード

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();

		if (n == 1 && s[0] == 'w') {
			System.out.println("No");
			return;
		}

		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