結果

問題 No.351 市松スライドパズル
ユーザー 👑 obakyanobakyan
提出日時 2019-05-05 10:37:03
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 428 ms / 2,000 ms
コード長 592 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 5,296 KB
実行使用メモリ 21,136 KB
最終ジャッジ日時 2023-09-06 15:24:01
合計ジャッジ時間 7,061 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 352 ms
18,964 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 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,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 418 ms
19,960 KB
testcase_14 AC 422 ms
19,816 KB
testcase_15 AC 426 ms
19,972 KB
testcase_16 AC 428 ms
19,972 KB
testcase_17 AC 386 ms
19,480 KB
testcase_18 AC 384 ms
20,360 KB
testcase_19 AC 405 ms
19,872 KB
testcase_20 AC 406 ms
21,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local ior = io.input()
local h, w, n = ior:read("*n", "*n", "*n", "*l")
local way, pos = {}, {}
local str = ""
for i = 1, n do
  str = ior:read()
  local a, b = str:match("(%w) (%d+)")
  way[i], pos[i] = a, tonumber(b)
end
local curcol, currow = 0, 0
for i = n, 1, -1 do
  if(way[i] == "C") then
    if(curcol == pos[i]) then
      currow = currow - 1
      if(currow == -1) then currow = h - 1 end
    end
  else
    if(currow == pos[i]) then
      curcol = curcol - 1
      if(curcol == -1) then curcol = w - 1 end
    end
  end
end
print((curcol + currow) % 2 == 1 and "black" or "white")
0