結果

問題 No.351 市松スライドパズル
ユーザー te-shte-sh
提出日時 2017-07-11 11:17:38
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 209 ms / 2,000 ms
コード長 697 bytes
コンパイル時間 1,595 ms
コンパイル使用メモリ 147,716 KB
実行使用メモリ 9,716 KB
最終ジャッジ日時 2023-09-03 15:07:37
合計ジャッジ時間 5,813 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 183 ms
9,116 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 205 ms
9,432 KB
testcase_14 AC 204 ms
8,912 KB
testcase_15 AC 206 ms
8,908 KB
testcase_16 AC 209 ms
9,228 KB
testcase_17 AC 200 ms
8,848 KB
testcase_18 AC 196 ms
9,716 KB
testcase_19 AC 202 ms
9,168 KB
testcase_20 AC 204 ms
9,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd1 = readln.split.to!(int[]), h = rd1[0], w = rd1[1];
  auto n = readln.chomp.to!size_t;

  auto s = new char[](n), k = new int[](n);
  foreach (i; 0..n) {
    auto rd2 = readln.chomp;
    s[i] = rd2[0];
    k[i] = rd2[2..$].to!int;
  }

  auto x = 0, y = 0;
  foreach_reverse (si, ki; lockstep(s, k)) {
    switch (si) {
    case 'R':
      if (y == ki) {
        --x;
        if (x < 0) x = w-1;
      }
      break;
    case 'C':
      if (x == ki) {
        --y;
        if (y < 0) y = h-1;
      }
      break;
    default:
      assert(0);
    }
  }

  writeln((x + y) % 2 == 0 ? "white" : "black");
}
0