結果
問題 |
No.351 市松スライドパズル
|
ユーザー |
![]() |
提出日時 | 2016-10-16 20:54:59 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 1,905 ms / 2,000 ms |
コード長 | 669 bytes |
コンパイル時間 | 3,832 ms |
コンパイル使用メモリ | 77,532 KB |
実行使用メモリ | 64,520 KB |
最終ジャッジ日時 | 2024-11-22 12:15:58 |
合計ジャッジ時間 | 25,213 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 17 |
ソースコード
import java.util.Scanner; public class Test { public static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int h = sc.nextInt(), w = sc.nextInt(), n = sc.nextInt(); int x = 0, y = 0; int[] m = new int[n]; char[] c = new char[n]; for(int i = 0; i < n; i++){ c[i] = sc.next().charAt(0); m[i] = sc.nextInt(); } for(int i = n-1; i >= 0; i--){ if(y == m[i] && c[i] == 'R'){ x--; if(x < 0){ x += w; } } else if(x == m[i] && c[i] == 'C'){ y--; if(y < 0){ y += h; } } } if((x + y) % 2 == 0){ System.out.println("white"); } else { System.out.println("black"); } } }