Rezultati

Up. imeNalogaJezikRezultatČas oddaje
PIN Jungle Speed Python 100/100OK 11. maj '17 @ 18:00

Test Točke Porabljen spomin Porabljen čas Status
#1 9/9 6,492 MiB 0,000 s OK
#2 9/9 6,492 MiB 0,000 s OK
#3 9/9 6,457 MiB 0,000 s OK
#4 9/9 6,492 MiB 0,000 s OK
#5 9/9 6,457 MiB 0,000 s OK
#6 9/9 6,484 MiB 0,000 s OK
#7 9/9 6,457 MiB 0,000 s OK
#8 9/9 6,457 MiB 0,000 s OK
#9 9/9 6,457 MiB 0,000 s OK
#10 9/9 6,492 MiB 0,000 s OK
#11 10/10 6,461 MiB 0,000 s OK

Ocenjevani program (jungle.py):
import sys
import copy

[playersCnt] = map(int, raw_input().split())
package = map(int, raw_input().split())

#print playersCnt
#print package

playersHands = {}
playersDesks = {}

i = 1
while i <= playersCnt:
	playersHands[i] = []
	playersDesks[i] = []
	i += 1
	
# Deal
n = len(package)
i = n - 1
while i >= 0:
	playersHands[(i % playersCnt) + 1].append(package[i])	
	i -= 1
'''
print "START:"	
print playersHands
print playersDesks
print ""
'''
i = 1
x = 0;
#while(x < 100):
while(1):
	#print "Player " + str(i) + ":"
	if len(playersHands[i]) == 0:
		playersHands[i] = copy.deepcopy(playersDesks[i])
		playersDesks[i] = []
	#print "  card " + str(playersHands[i][0]) + " goes on desk"
	playersDesks[i].append(playersHands[i][0])
	del playersHands[i][0]
	#print "  newHand: " + str(playersHands[i]) + ", newDesk: " + str(playersDesks[i])
	
	j = 0
	while j < playersCnt:
		plr = (j % playersCnt) + 1
		plrDeskSize = len(playersDesks[plr])
		if plr != i and plrDeskSize > 0 and playersDesks[plr][plrDeskSize - 1] == playersDesks[i][-1]:
		#	print "  player " + str(plr) + " has desk: " + str(playersDesks[plr]) + " => merge"
			newDesk = playersDesks[plr] + playersDesks[i]
			#print "  newDesk: " + str(newDesk)
			playersDesks[i] = []
			playersDesks[plr] = []
			playersHands[i] += (newDesk)
			#print "  new Hands: " + str(playersHands) + ", new Desks: " + str(playersDesks)
			if len(playersHands[plr]) == 0:
				print plr
				exit()
			i -= 1
			break
		j += 1
	
	i += 1
	if(i > playersCnt):
		i = 1
	
	x += 1