結果

問題 No.351 市松スライドパズル
ユーザー Tsuneo Yoshioka
提出日時 2016-03-11 23:15:13
言語 Ruby
(3.4.1)
結果
AC  
実行時間 1,257 ms / 2,000 ms
コード長 588 bytes
コンパイル時間 45 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 22,656 KB
最終ジャッジ日時 2024-09-25 02:35:18
合計ジャッジ時間 14,052 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

H,W=gets.split.map(&:to_i)
N = gets.to_i
ops = []
BIG=100000
N.times{
    s,k=gets.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