結果

問題 No.1909 Detect from Substrings
ユーザー 37zigen37zigen
提出日時 2022-04-22 21:16:55
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 946 bytes
コンパイル時間 2,393 ms
コンパイル使用メモリ 74,532 KB
実行使用メモリ 66,184 KB
最終ジャッジ日時 2023-09-06 07:32:22
合計ジャッジ時間 16,437 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,784 KB
testcase_01 AC 126 ms
55,864 KB
testcase_02 AC 125 ms
55,584 KB
testcase_03 AC 147 ms
56,984 KB
testcase_04 AC 209 ms
56,672 KB
testcase_05 AC 295 ms
61,428 KB
testcase_06 AC 330 ms
63,364 KB
testcase_07 AC 322 ms
63,404 KB
testcase_08 AC 294 ms
63,904 KB
testcase_09 AC 302 ms
63,948 KB
testcase_10 AC 324 ms
61,796 KB
testcase_11 AC 344 ms
61,468 KB
testcase_12 AC 408 ms
62,012 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main implements Runnable { //Runnableを実装する
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行
    }
	
	public void run() {
		Scanner sc=new Scanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		
		int N=sc.nextInt();
		int M=sc.nextInt();
		char[][] str=new char[N][M];
		for (int i=0;i<N;++i) str[i]=sc.next().toCharArray();
		
		if (N>2) {
			pw.println(0);
		} else {
			
			boolean eq1=true;
			boolean eq2=true;
			for (int i=0;i<N-1;++i) eq1&=str[0][i]==str[1][i+1];
			for (int i=0;i<N-1;++i) eq2&=str[0][i+1]==str[1][i];
			int ans=0;
			if (eq1) ++ans;
			if (eq2) ++ans;
			pw.println(ans);
		}
		pw.close();
		
	}	
	
	void tr(Object ... o) {System.out.println(Arrays.deepToString(o));}
}
0