結果

問題 No.2373 wa, wo, n
ユーザー tentententen
提出日時 2023-07-11 14:19:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 2,526 bytes
コンパイル時間 2,768 ms
コンパイル使用メモリ 86,872 KB
実行使用メモリ 53,228 KB
最終ジャッジ日時 2023-10-11 05:26:25
合計ジャッジ時間 7,520 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,316 KB
testcase_01 AC 43 ms
49,660 KB
testcase_02 AC 43 ms
49,632 KB
testcase_03 AC 44 ms
49,388 KB
testcase_04 AC 43 ms
49,628 KB
testcase_05 AC 44 ms
49,268 KB
testcase_06 AC 44 ms
49,412 KB
testcase_07 AC 43 ms
49,368 KB
testcase_08 AC 44 ms
49,528 KB
testcase_09 AC 44 ms
49,416 KB
testcase_10 AC 43 ms
49,820 KB
testcase_11 AC 43 ms
49,436 KB
testcase_12 AC 43 ms
49,388 KB
testcase_13 AC 42 ms
49,444 KB
testcase_14 AC 106 ms
52,532 KB
testcase_15 AC 53 ms
49,832 KB
testcase_16 AC 108 ms
52,516 KB
testcase_17 AC 56 ms
50,968 KB
testcase_18 AC 46 ms
49,264 KB
testcase_19 AC 76 ms
51,460 KB
testcase_20 AC 95 ms
52,156 KB
testcase_21 AC 77 ms
51,476 KB
testcase_22 AC 78 ms
51,576 KB
testcase_23 AC 95 ms
52,176 KB
testcase_24 AC 44 ms
49,380 KB
testcase_25 AC 44 ms
49,488 KB
testcase_26 AC 44 ms
49,468 KB
testcase_27 AC 43 ms
49,380 KB
testcase_28 AC 43 ms
49,356 KB
testcase_29 AC 44 ms
49,372 KB
testcase_30 AC 44 ms
49,280 KB
testcase_31 AC 43 ms
49,408 KB
testcase_32 AC 111 ms
50,740 KB
testcase_33 AC 98 ms
52,132 KB
testcase_34 AC 108 ms
52,500 KB
testcase_35 AC 100 ms
52,320 KB
testcase_36 AC 106 ms
52,624 KB
testcase_37 AC 106 ms
52,460 KB
testcase_38 AC 104 ms
52,152 KB
testcase_39 AC 108 ms
50,788 KB
testcase_40 AC 109 ms
52,292 KB
testcase_41 AC 100 ms
52,396 KB
testcase_42 AC 107 ms
53,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        char prev = 'n';
        for (char c : sc.next().toCharArray()) {
            if (c == 'w') {
                if (prev == 'w') {
                    System.out.println("No");
                    return;
                }
                prev = 'w';
            } else if (c == 'a' || c == 'o') {
                if (prev != 'w' && prev != '?') {
                    System.out.println("No");
                    return;
                }
                prev = 'a';
            } else if (c == 'n') {
                if (prev == 'w') {
                    System.out.println("No");
                    return;
                }
                prev = 'n';
            } else if (c == '?') {
                if (prev == 'w') {
                    prev = 'a';
                } else {
                    prev = '?';
                }
            } else {
                System.out.println("No");
                return;
            }
        }
        if (prev == 'w') {
            System.out.println("No");
            return;
        }
        System.out.println("Yes");
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0