Rezultati

Up. imeNalogaJezikRezultatČas oddaje
_NABLA-2017 Jungle Speed Python 3 100/100OK 11. maj '17 @ 19:13

Test Točke Porabljen spomin Porabljen čas Status
#1 9/9 8,602 MiB 0,000 s OK
#2 9/9 8,605 MiB 0,000 s OK
#3 9/9 8,629 MiB 0,000 s OK
#4 9/9 8,609 MiB 0,000 s OK
#5 9/9 8,617 MiB 0,000 s OK
#6 9/9 8,594 MiB 0,000 s OK
#7 9/9 8,539 MiB 0,000 s OK
#8 9/9 8,621 MiB 0,000 s OK
#9 9/9 8,594 MiB 0,000 s OK
#10 9/9 8,617 MiB 0,000 s OK
#11 10/10 8,586 MiB 0,000 s OK

Ocenjevani program (jungle_speed.py):
N = int(input())
game = [[[],[]] for x in range(N)]
cards = [int(x) for x in input().split()]
player = 0
for card in cards:
	game[player][0].append(card)
	player = (player+1) % N

player = 0
while True:
	for ply in range(N):
		flag = False
		if game[ply][0] == [] and game[ply][1] == []:
			print(ply + 1)
			flag = True
			break
	if flag:
		break
	
	
	if game[player][0] == []:
		game[player][0] = game[player][1][::-1]
		game[player][1] = []
	
	game[player][1].append(game[player][0].pop())
	
	for ply in range(N):
		if ply == player:
			continue
		if game[ply][1]:
			if game[player][1][-1] == game[ply][1][-1]:
				game[player][1] = game[ply][1] + game[player][1]
				game[ply][1] = []
				game[player][1] = game[player][1][::-1]
				game[player][0] = game[player][1] + game[player][0]
				game[player][1] = []
				break
	else:
		player = (player+1) % N