結果

問題 No.351 市松スライドパズル
ユーザー 37zigen37zigen
提出日時 2016-04-01 20:01:07
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,586 ms / 2,000 ms
コード長 869 bytes
コンパイル時間 2,065 ms
コンパイル使用メモリ 77,212 KB
実行使用メモリ 153,728 KB
最終ジャッジ日時 2024-04-10 07:13:08
合計ジャッジ時間 20,224 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,564 ms
150,624 KB
testcase_01 AC 116 ms
55,976 KB
testcase_02 AC 104 ms
53,008 KB
testcase_03 AC 118 ms
53,840 KB
testcase_04 AC 115 ms
54,396 KB
testcase_05 AC 120 ms
54,036 KB
testcase_06 AC 115 ms
53,872 KB
testcase_07 AC 116 ms
53,904 KB
testcase_08 AC 115 ms
53,964 KB
testcase_09 AC 121 ms
54,060 KB
testcase_10 AC 112 ms
53,456 KB
testcase_11 AC 122 ms
54,236 KB
testcase_12 AC 124 ms
53,816 KB
testcase_13 AC 1,569 ms
146,392 KB
testcase_14 AC 1,424 ms
147,928 KB
testcase_15 AC 1,565 ms
153,728 KB
testcase_16 AC 1,455 ms
151,656 KB
testcase_17 AC 1,467 ms
151,696 KB
testcase_18 AC 1,515 ms
151,612 KB
testcase_19 AC 1,524 ms
151,404 KB
testcase_20 AC 1,586 ms
151,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder351;
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		int h=Integer.parseInt(sc.next());
		int w=Integer.parseInt(sc.next());
		int n=Integer.parseInt(sc.next());
		int x=0;
		int y=0;
		String[] s=new String[n];
		int[] k=new int[n];
		for(int i=0;i<n;i++){
			s[i]=sc.next();
			//行の操作R、列の操作C
			k[i]=Integer.parseInt(sc.next());
		}
		for(int i=n-1;i>=0;i--){
			if(s[i].equals("R")&&k[i]==y){
				if(x==0){
					x=w-1;
				}else if(x!=0){
					x--;
				}
			}else if(s[i].equals("C")&&k[i]==x){
				if(y==0){
					y=h-1;
				}else if(y!=0){
					y--;
				}
			}
		}
		if((x+y)%2==0){
			pw.println("white");
		}else if((x+y)%2==1){
			pw.println("black");
		}
		pw.close();
	}
}
0