結果

問題 No.2535 多重同値
ユーザー kusagame12kusagame12
提出日時 2024-03-04 19:20:47
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,187 bytes
コンパイル時間 2,421 ms
コンパイル使用メモリ 77,248 KB
実行使用メモリ 78,716 KB
最終ジャッジ日時 2024-03-04 19:20:57
合計ジャッジ時間 9,829 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 145 ms
64,388 KB
testcase_01 WA -
testcase_02 AC 131 ms
57,544 KB
testcase_03 AC 134 ms
57,828 KB
testcase_04 WA -
testcase_05 AC 129 ms
57,956 KB
testcase_06 WA -
testcase_07 AC 125 ms
57,720 KB
testcase_08 AC 124 ms
57,576 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 128 ms
57,696 KB
testcase_12 WA -
testcase_13 AC 126 ms
57,840 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1,297 ms
69,152 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
       
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
       
        boolean[] isTrue = new boolean[N+1];
        
        for(int i = 1 ; i <= N ; i++){
            String yOrN = sc.next();
            if(yOrN.equals("Yes")){
                isTrue[i] = true;
            }else{
                isTrue[i] = false;
            }
        }
       
        if(isTrue[1]){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
       
        for(int i = 2 ; i <= N ; i++){
            
            if(isMatch(isTrue , 1 , i) == isTrue[1]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }
      
        
    }
    
    private static boolean isMatch(boolean[] isTrue , int l, int r){
        if(l != r){
            if(isMatch(isTrue , l+1 , r) == isTrue[l]){
                return true;
            }else{
                return false;
            }
        }else{
            return isTrue[r];
        }
    }
   
}
0