結果

問題 No.769 UNOシミュレータ
ユーザー kamomekamome
提出日時 2020-05-13 00:09:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 797 ms / 2,000 ms
コード長 2,064 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,904 KB
最終ジャッジ日時 2024-09-14 03:37:35
合計ジャッジ時間 7,751 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 30 ms
10,880 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 32 ms
10,752 KB
testcase_04 AC 33 ms
10,752 KB
testcase_05 AC 33 ms
10,880 KB
testcase_06 AC 32 ms
10,752 KB
testcase_07 AC 33 ms
10,880 KB
testcase_08 AC 33 ms
10,880 KB
testcase_09 AC 56 ms
10,880 KB
testcase_10 AC 55 ms
10,752 KB
testcase_11 AC 56 ms
10,752 KB
testcase_12 AC 278 ms
10,880 KB
testcase_13 AC 282 ms
10,880 KB
testcase_14 AC 285 ms
11,008 KB
testcase_15 AC 530 ms
11,392 KB
testcase_16 AC 539 ms
11,264 KB
testcase_17 AC 535 ms
11,264 KB
testcase_18 AC 797 ms
11,648 KB
testcase_19 AC 768 ms
11,776 KB
testcase_20 AC 794 ms
11,520 KB
testcase_21 AC 788 ms
11,904 KB
testcase_22 AC 31 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class UNOSim:
    """ Class doc """
    
    def __init__ (self,N):
        """ Class initialiser """
        self.player_N  = N-1
        self.prev_card = ""
        self.magnifi   = 0
        self.rev       = False
        self.players   = [ 0 for x in range(N)]
        self.turn      = -1

    def drop(self,card):
        self.progress()
        
        if  self.prev_card == "skip":
            self.progress()
            self.prev_card=""

        elif self.prev_card == "drawtwo" and card != "drawtwo":
            self.players[self.turn] = self.players[self.turn] - 2 * self.magnifi
            self.prev_card=""
            self.magnifi = 0
            self.progress()
        
        elif self.prev_card == "drawfour" and card != "drawfour":
            self.players[self.turn] = self.players[self.turn] - 4 * self.magnifi
            self.prev_card=""
            self.magnifi = 0
            self.progress()
            
        if card == "number": # "number", "drawtwo", "drawfour", "skip", "reverse"
            self.players[self.turn] = self.players[self.turn] + 1
            
        elif card == "drawtwo" or card == "drawfour":
            self.prev_card = card
            self.magnifi = self.magnifi + 1
            self.players[self.turn] = self.players[self.turn] + 1

        elif card == "skip":
            self.prev_card = "skip"
            self.players[self.turn] = self.players[self.turn] + 1
        
        elif card == "reverse":
            self.rev = not self.rev
            self.players[self.turn] = self.players[self.turn] + 1

    def progress(self):
        if self.rev != True: # normal
            if self.player_N == self.turn:
                self.turn = 0
            else:
                self.turn = self.turn + 1
        else: # reversed
            if self.turn == 0:
                self.turn = self.player_N
            else:
                self.turn = self.turn - 1    
N,M=map(int,input().split())
a=UNOSim(N)
for i in range(M):
    a.drop(input())
print("{} {}".format(a.turn+1,a.players[a.turn]))
    
0