結果

問題 No.351 市松スライドパズル
ユーザー 37zigen37zigen
提出日時 2016-04-01 22:06:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,147 ms / 2,000 ms
コード長 1,895 bytes
コンパイル時間 4,476 ms
コンパイル使用メモリ 77,920 KB
実行使用メモリ 132,864 KB
最終ジャッジ日時 2023-10-25 07:43:53
合計ジャッジ時間 16,231 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,052 ms
129,544 KB
testcase_01 AC 57 ms
52,548 KB
testcase_02 AC 58 ms
52,580 KB
testcase_03 AC 58 ms
53,576 KB
testcase_04 AC 57 ms
53,596 KB
testcase_05 AC 58 ms
52,528 KB
testcase_06 AC 57 ms
53,584 KB
testcase_07 AC 57 ms
53,588 KB
testcase_08 AC 57 ms
53,588 KB
testcase_09 AC 57 ms
53,588 KB
testcase_10 AC 58 ms
53,592 KB
testcase_11 AC 58 ms
52,568 KB
testcase_12 AC 57 ms
53,532 KB
testcase_13 AC 1,053 ms
132,612 KB
testcase_14 AC 1,049 ms
132,864 KB
testcase_15 AC 1,136 ms
131,568 KB
testcase_16 AC 1,126 ms
131,404 KB
testcase_17 AC 1,147 ms
132,176 KB
testcase_18 AC 1,084 ms
132,460 KB
testcase_19 AC 1,125 ms
129,516 KB
testcase_20 AC 1,133 ms
129,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder351;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Iterator;

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		Printer pr=new Printer(System.out);
		int h=sc.nextInt();
		int w=sc.nextInt();
		int n=sc.nextInt();
		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]=sc.nextInt();
		}
		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--;
				}
			}
		}
		pr.println((x+y)%2==0?"white":"black");
		pr.close();
		sc.close();
	}
	private static class Scanner{
		BufferedReader br;
		Iterator<String> it;
		Scanner(InputStream in){
			br=new BufferedReader(new InputStreamReader(in));
		}
		String next()throws RuntimeException{
			try{
				if(it==null||!it.hasNext()){
					it=Arrays.asList(br.readLine().split(" ")).iterator();
				}
				return it.next();
			}catch(IOException e){
				throw new IllegalStateException();
			}
		}
		int nextInt() throws RuntimeException{
			return Integer.parseInt(next());
		}
		long nextLong() throws RuntimeException{
			return Long.parseLong(next());
		}
		float nextFloat() throws RuntimeException{
			return Float.parseFloat(next());
		}
		double nextDouble() throws RuntimeException{
			return Double.parseDouble(next());
		}
		void close(){
			try{
				br.close();
			}catch(IOException e){
				throw new IllegalStateException();
			}
		}
	}
	private static class Printer extends PrintWriter{
		Printer(PrintStream out){
			super(out);
		}
	}
}
0