結果

問題 No.351 市松スライドパズル
コンテスト
ユーザー 37zigen
提出日時 2016-04-01 20:01:07
言語 Java
(openjdk 27 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
AC  
実行時間 943 ms / 2,000 ms
+ 715µs
コード長 869 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,489 ms
コンパイル使用メモリ 86,372 KB
実行使用メモリ 132,892 KB
最終ジャッジ日時 2026-09-08 19:21:50
合計ジャッジ時間 15,516 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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