結果

問題 No.351 市松スライドパズル
ユーザー 37zigen37zigen
提出日時 2016-03-12 04:13:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,247 ms / 2,000 ms
コード長 709 bytes
コンパイル時間 3,656 ms
コンパイル使用メモリ 77,884 KB
実行使用メモリ 75,224 KB
最終ジャッジ日時 2023-10-25 06:36:10
合計ジャッジ時間 18,921 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,139 ms
75,036 KB
testcase_01 AC 133 ms
57,112 KB
testcase_02 AC 134 ms
57,100 KB
testcase_03 AC 134 ms
57,100 KB
testcase_04 AC 135 ms
57,108 KB
testcase_05 AC 136 ms
57,100 KB
testcase_06 AC 136 ms
57,164 KB
testcase_07 AC 137 ms
57,620 KB
testcase_08 AC 134 ms
57,484 KB
testcase_09 AC 139 ms
57,488 KB
testcase_10 AC 140 ms
57,484 KB
testcase_11 AC 143 ms
57,716 KB
testcase_12 AC 144 ms
57,752 KB
testcase_13 AC 1,244 ms
75,036 KB
testcase_14 AC 1,232 ms
74,976 KB
testcase_15 AC 1,232 ms
74,872 KB
testcase_16 AC 1,234 ms
75,224 KB
testcase_17 AC 1,240 ms
74,876 KB
testcase_18 AC 1,233 ms
74,840 KB
testcase_19 AC 1,247 ms
74,824 KB
testcase_20 AC 1,242 ms
74,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package 練習;
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=sc.nextInt();
		int w=sc.nextInt();
		int n=sc.nextInt();
		int x=0;
		int y=0;
		char[] s=new char[n];
		int[] k=new int[n];

		for(int i=0;i<n;i++){
			s[i]=sc.next().toCharArray()[0];
			k[i]=Integer.parseInt(sc.next());
		}
		for(int i=n-1;i>=0;i--){
			if(s[i]=='R'&&k[i]==y){
				x=(x-1+w)%w;
			}else if(s[i]=='C'&&k[i]==x){
				y=(y-1+h)%h;
			}
		}

		if((x+y)%2==0){
			pw.println("white");
		}else if((x+y)%2==1){
			pw.println("black");
		}
		pw.close();
		sc.close();
	}
}

0