結果

問題 No.351 市松スライドパズル
ユーザー Tsuneo YoshiokaTsuneo Yoshioka
提出日時 2016-03-11 23:22:25
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,159 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 61 ms
コンパイル使用メモリ 11,964 KB
実行使用メモリ 99,244 KB
最終ジャッジ日時 2023-10-25 07:18:03
合計ジャッジ時間 13,203 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,159 ms
99,244 KB
testcase_01 AC 86 ms
16,128 KB
testcase_02 AC 85 ms
16,128 KB
testcase_03 AC 86 ms
16,128 KB
testcase_04 AC 85 ms
16,128 KB
testcase_05 AC 84 ms
16,128 KB
testcase_06 AC 85 ms
16,128 KB
testcase_07 AC 85 ms
16,124 KB
testcase_08 AC 87 ms
16,128 KB
testcase_09 AC 86 ms
16,128 KB
testcase_10 AC 85 ms
16,128 KB
testcase_11 AC 84 ms
16,128 KB
testcase_12 AC 86 ms
16,128 KB
testcase_13 AC 1,065 ms
98,572 KB
testcase_14 AC 1,071 ms
98,712 KB
testcase_15 AC 1,076 ms
99,228 KB
testcase_16 AC 1,068 ms
99,244 KB
testcase_17 AC 1,063 ms
99,244 KB
testcase_18 AC 1,050 ms
99,244 KB
testcase_19 AC 1,077 ms
99,244 KB
testcase_20 AC 1,075 ms
99,244 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

H,W=gets.split.map(&:to_i)
N = gets.to_i
ops = []
BIG=100000
STDIN.read.split("\n").map{|line|
    s,k=line.split
    k = k.to_i
    if s=='R'
        ops << k 
    else
        ops << k + BIG
    end
#    ops << [s, k]
}
# ops.reverse!
x=0
y=0
count = 0
ops.reverse_each{|op|
    if op < BIG && op == y
        count +=1
        x = (x+W-1)%W
        if x==W-1 && W%2==1
            count +=1
        end
    elsif op >= BIG && op - BIG == x
        count += 1
        y = (y+H-1)%H
        if y==H-1 && H%2==1
            count +=1
        end
    end
}
if count%2==0
    puts 'white'
else
    puts 'black'
end
0