結果
問題 |
No.351 市松スライドパズル
|
ユーザー |
![]() |
提出日時 | 2018-09-17 15:05:55 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 738 bytes |
コンパイル時間 | 2,161 ms |
コンパイル使用メモリ | 76,904 KB |
実行使用メモリ | 156,160 KB |
最終ジャッジ日時 | 2024-07-18 07:40:34 |
合計ジャッジ時間 | 27,746 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 5 WA * 3 TLE * 9 |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int H = scan.nextInt(); int W = scan.nextInt(); int N = scan.nextInt(); String []S = new String[N]; int []K = new int[N]; for(int i = 0; i < N; i++) { S[i] = scan.next(); K[i] = scan.nextInt(); } scan.close(); int r = 0; int c = 0; for(int i = N - 1; i >= 0; i--) { if(S[i].equals("R") && r == K[i]) { if(c == 0) { c = W - 1; }else { c = c - 1; } }else if(c == K[i]) { if(r == 0) { r = H - 1; }else { r = r - 1; } } } if((r + c) % 2 == 0) { System.out.println("white"); }else { System.out.println("black"); } } }