Rezultati

Up. imeNalogaJezikRezultatČas oddaje
kjejenovictk-2019 Revolver Python 3 0/100Napaka med izvajanjem / ob izhodu (RTE) 09. maj '19 @ 20:13

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 0/14 8,766 MiB 0,000 s Program je končal z neničelno kodo
Stderr:
Traceback (most recent call last):
  File "source.py3", line 51, in <module>
    islands_shot = get_shot_islands(islands,p)
  File "source.py3", line 41, in get_shot_islands
    islands_shot.append(sum(line)/n)
ZeroDivisionError: division by zero
#2 [več] 0/14 8,680 MiB 0,000 s Program je končal z neničelno kodo
Stderr:
Traceback (most recent call last):
  File "source.py3", line 51, in <module>
    islands_shot = get_shot_islands(islands,p)
  File "source.py3", line 41, in get_shot_islands
    islands_shot.append(sum(line)/n)
ZeroDivisionError: division by zero
#3 [več] 0/14 8,770 MiB 0,000 s Program je končal z neničelno kodo
Stderr:
Traceback (most recent call last):
  File "source.py3", line 51, in <module>
    islands_shot = get_shot_islands(islands,p)
  File "source.py3", line 41, in get_shot_islands
    islands_shot.append(sum(line)/n)
ZeroDivisionError: division by zero
#4 [več] 0/14 8,629 MiB 0,000 s Program je končal z neničelno kodo
Stderr:
Traceback (most recent call last):
  File "source.py3", line 51, in <module>
    islands_shot = get_shot_islands(islands,p)
  File "source.py3", line 41, in get_shot_islands
    islands_shot.append(sum(line)/n)
ZeroDivisionError: division by zero
#5 [več] 0/14 8,668 MiB 0,000 s Program je končal z neničelno kodo
Stderr:
Traceback (most recent call last):
  File "source.py3", line 51, in <module>
    islands_shot = get_shot_islands(islands,p)
  File "source.py3", line 41, in get_shot_islands
    islands_shot.append(sum(line)/n)
ZeroDivisionError: division by zero
#6 [več] 0/15 8,805 MiB 0,000 s Program je končal z neničelno kodo
Stderr:
Traceback (most recent call last):
  File "source.py3", line 51, in <module>
    islands_shot = get_shot_islands(islands,p)
  File "source.py3", line 41, in get_shot_islands
    islands_shot.append(sum(line)/n)
ZeroDivisionError: division by zero
#7 [več] 0/15 8,602 MiB 0,000 s Program je končal z neničelno kodo
Stderr:
Traceback (most recent call last):
  File "source.py3", line 51, in <module>
    islands_shot = get_shot_islands(islands,p)
  File "source.py3", line 41, in get_shot_islands
    islands_shot.append(sum(line)/n)
ZeroDivisionError: division by zero

Ocenjevani program (revolver.py):
import sys
data = sys.stdin.readlines()
#data = open("/home/putka-kjejenovictk-2019/Desktop/revolverTest").readlines()

T = int(data[0])

def get_islands(revstring):
    islands = []
    curr_islands = 0
    k = 0

    for i in revstring:
        if i == ".":
            curr_islands += 1
        else:
            k += 1
            if curr_islands != 0:
                islands.append(curr_islands)
                curr_islands = 0
    else:
        if curr_islands != 0:
            islands.append(curr_islands)

    if revstring[0] == revstring[-1]:
        islands[0] += islands[-1]
        del islands[-1]

    return k,islands

def get_shot_islands(islands,p):
    islands_shot = []
    n = sum(islands)
    for i in range(1,p):
        line = []
        for island in islands:
            val = island - i
            if val < 0:
                line.append(0)
            else:
                line.append(val)
        islands_shot.append(sum(line)/n)
        n -= 1
    return islands_shot


for testcase in range(1,2*T,2):
    n,p = list(map(int,data[testcase].strip().split()))
    revstring = data[testcase+1].strip()
    n_shot = 1
    k,islands = get_islands(revstring)
    islands_shot = get_shot_islands(islands,p)
    prob_roll = (n-k)/n
    prob = prob_roll
    firing = []
    cur_shot_row = 0


    # for i in revstring:
    #     if n_shot == p:
    #         #KONCALI SMO!!!!!!!
    #         break
    #
    #     if i == ".":
    #         firing.append("FIRE")
    #         n_shot += 1
    #     else:
    #         firing.append("ROLL")
    #         n_shot += 1
    #         prob *= prob_roll
    #         cur_shot_row += 1
    #         break
    #
    # if n_shot == p:
    #     print(prob)
    #     for i in firing:
    #         print(i)
    #     continue


    while n_shot < p:
        #print(prob)
        prob_shot = islands_shot[cur_shot_row]

        if prob_shot > prob_roll:
            #print(prob_shot,prob_roll)
            firing.append("FIRE")
            n_shot += 1
            cur_shot_row += 1
            prob *= prob_shot
        else:
            firing.append("ROLL")
            n_shot += 1
            cur_shot_row = 0
            prob *= prob_roll


    print(prob)
    for i in firing:
        print(i)