結果
問題 |
No.351 市松スライドパズル
|
ユーザー |
|
提出日時 | 2016-03-12 00:11:05 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 879 ms / 2,000 ms |
コード長 | 1,063 bytes |
コンパイル時間 | 2,258 ms |
コンパイル使用メモリ | 77,500 KB |
実行使用メモリ | 162,564 KB |
最終ジャッジ日時 | 2024-09-25 02:40:57 |
合計ジャッジ時間 | 12,364 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 17 |
ソースコード
// JavaでTLE叩き出して恥ずかしい。 import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { try (InputStreamReader isr = new InputStreamReader(System.in)) { StringBuilder sb = new StringBuilder(); char[] cbuf = new char[4000]; int size; while ((size = isr.read(cbuf)) >= 0) { sb.append(cbuf, 0, size); } String[] lines = sb.toString().split("\n"); String[] ary = lines[0].trim().split(" "); int h = Integer.parseInt(ary[0]); int w = Integer.parseInt(ary[1]); int x = 0; int y = 0; for (int i = lines.length - 1; i >= 2; i--) { ary = lines[i].trim().split(" "); String s = ary[0]; int k = Integer.parseInt(ary[1]); if ("R".equals(s) && k == y) { x--; if (x < 0) x = w - 1; } else if ("C".equals(s) && k == x) { y--; if (y < 0) y = h - 1; } // System.err.println(String.format("%s %d (%d, %d)", s, k, x, y)); } System.out.println((x + y) % 2 == 0 ? "white" : "black"); } } }