結果

問題 No.769 UNOシミュレータ
ユーザー maimai
提出日時 2018-12-16 22:32:15
言語 Ruby
(3.3.0)
結果
AC  
実行時間 363 ms / 2,000 ms
コード長 1,111 bytes
コンパイル時間 364 ms
コンパイル使用メモリ 11,608 KB
実行使用メモリ 35,184 KB
最終ジャッジ日時 2023-08-14 11:52:21
合計ジャッジ時間 5,046 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
15,052 KB
testcase_01 AC 72 ms
15,196 KB
testcase_02 AC 69 ms
15,324 KB
testcase_03 AC 68 ms
15,028 KB
testcase_04 AC 69 ms
15,096 KB
testcase_05 AC 69 ms
15,228 KB
testcase_06 AC 70 ms
15,048 KB
testcase_07 AC 73 ms
15,188 KB
testcase_08 AC 73 ms
15,136 KB
testcase_09 AC 80 ms
15,812 KB
testcase_10 AC 81 ms
15,616 KB
testcase_11 AC 79 ms
15,640 KB
testcase_12 AC 163 ms
21,608 KB
testcase_13 AC 160 ms
21,724 KB
testcase_14 AC 159 ms
21,868 KB
testcase_15 AC 255 ms
29,280 KB
testcase_16 AC 253 ms
28,904 KB
testcase_17 AC 260 ms
29,076 KB
testcase_18 AC 349 ms
35,184 KB
testcase_19 AC 363 ms
34,908 KB
testcase_20 AC 336 ms
35,020 KB
testcase_21 AC 334 ms
35,160 KB
testcase_22 AC 67 ms
15,292 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def ascan; gets.split.map(&:to_i); end

N, M = ascan

turn = 0
vec = 1
numcards = [1]*N

lastturn = 0

commands = M.times.map{gets.chomp}

draw = 0

idx = 0
while idx < M
    lastturn = turn
    c = commands[idx]
    
    if draw > 0
        if c == commands[idx-1]
            draw += c == 'drawtwo' ? 2 : 4
            numcards[turn] += 1
            turn += 1*vec
        else
            numcards[turn] -= draw
            turn += 1*vec
            draw = 0
            idx -= 1
        end
    else
        
        case c
        when 'number'
            numcards[turn] += 1
            turn += 1*vec
        when 'drawtwo'
            numcards[turn] += 1
            draw = 2
            turn += 1*vec
        when 'drawfour'
            numcards[turn] += 1
            draw = 4
            turn += 1*vec
        when 'skip'
            numcards[turn] += 1
            turn += 2*vec
        when 'reverse'
            numcards[turn] += 1
            vec *= -1
            turn += 1*vec
        end
        
    end
    turn = (turn + N) % N
    idx += 1
end

puts "#{lastturn+1} #{numcards[lastturn]-1}"
0