<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.universitas.ro/index.php?action=history&amp;feed=atom&amp;title=1136_-_Dragoni</id>
	<title>1136 - Dragoni - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.universitas.ro/index.php?action=history&amp;feed=atom&amp;title=1136_-_Dragoni"/>
	<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=1136_-_Dragoni&amp;action=history"/>
	<updated>2026-05-01T09:09:32Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://wiki.universitas.ro/index.php?title=1136_-_Dragoni&amp;diff=9146&amp;oldid=prev</id>
		<title>Rus Marius: Pagină nouă: == Enunț == Supărați că lansarea părții a treia a filmului lor preferat s-a amânat până în iunie 2018, Henry și Hetty s-au gândit la propriul scenariu pentru finalul trilogiei:  Într-o lume în care vikingii pot zbura cu dragonii există &lt;code&gt;N&lt;/code&gt; insule. Hiccup, șeful tribului de vikingi aflat pe insula &lt;code&gt;1&lt;/code&gt;, știe &lt;code&gt;M&lt;/code&gt; rute directe de zbor bidirecționale între insule. Pentru fiecare &lt;code&gt;j&lt;/code&gt; intre &lt;code&gt;1&lt;/code&gt; si &lt;code&gt;M&lt;/cod...</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=1136_-_Dragoni&amp;diff=9146&amp;oldid=prev"/>
		<updated>2024-01-06T22:05:33Z</updated>

		<summary type="html">&lt;p&gt;Pagină nouă: == Enunț == Supărați că lansarea părții a treia a filmului lor preferat s-a amânat până în iunie 2018, Henry și Hetty s-au gândit la propriul scenariu pentru finalul trilogiei:  Într-o lume în care vikingii pot zbura cu dragonii există &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; insule. Hiccup, șeful tribului de vikingi aflat pe insula &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;, știe &amp;lt;code&amp;gt;M&amp;lt;/code&amp;gt; rute directe de zbor bidirecționale între insule. Pentru fiecare &amp;lt;code&amp;gt;j&amp;lt;/code&amp;gt; intre &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; si &amp;lt;code&amp;gt;M&amp;lt;/cod...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Enunț ==&lt;br /&gt;
Supărați că lansarea părții a treia a filmului lor preferat s-a amânat până în iunie 2018, Henry și Hetty s-au gândit la propriul scenariu pentru finalul trilogiei:&lt;br /&gt;
&lt;br /&gt;
Într-o lume în care vikingii pot zbura cu dragonii există &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; insule. Hiccup, șeful tribului de vikingi aflat pe insula &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;, știe &amp;lt;code&amp;gt;M&amp;lt;/code&amp;gt; rute directe de zbor bidirecționale între insule. Pentru fiecare &amp;lt;code&amp;gt;j&amp;lt;/code&amp;gt; intre &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; si &amp;lt;code&amp;gt;M&amp;lt;/code&amp;gt;, ruta &amp;lt;code&amp;gt;j&amp;lt;/code&amp;gt; unește insulele &amp;lt;code&amp;gt;Aj&amp;lt;/code&amp;gt; și &amp;lt;code&amp;gt;Bj&amp;lt;/code&amp;gt; și are lungime &amp;lt;code&amp;gt;Dj&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Pe fiecare insulă &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt;, (&amp;lt;code&amp;gt;1 ≤ i ≤ n&amp;lt;/code&amp;gt;) există dragoni din specia &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt; care pot zbura fără a se opri pentru odihnă o distanță maximă &amp;lt;code&amp;gt;Dmaxi&amp;lt;/code&amp;gt;. Cu alte cuvinte, dragonii de pe insula &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt; vor putea parcurge orice rută &amp;lt;code&amp;gt;j&amp;lt;/code&amp;gt;, (&amp;lt;code&amp;gt;1 ≤ j ≤ m&amp;lt;/code&amp;gt;) pentru care &amp;lt;code&amp;gt;Dj ≤ Dmaxi&amp;lt;/code&amp;gt;, indiferent de ce alte drumuri au făcut anterior.&lt;br /&gt;
&lt;br /&gt;
Hiccup dorește să ajungă de pe insula &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; pe insula &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; pentru a-l salva pe Toothless, dragonul lui. Pentru a ajunge acolo, el va lua inițial un dragon din specia &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; (de pe insula &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;). Apoi, dacă la un moment dat Hiccup se află pe o insula &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt;, (&amp;lt;code&amp;gt;1 ≤ i ≤ n&amp;lt;/code&amp;gt;) având cu el un dragon din specia &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt;, el poate:&lt;br /&gt;
&lt;br /&gt;
# Să zboare de pe insula &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt; pe o altă insulă &amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt; cu dragonul pe care îl are, folosind o rută directă &amp;lt;code&amp;gt;j&amp;lt;/code&amp;gt; între insulele &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt; si &amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt;, bineînțeles doar dacă &amp;lt;code&amp;gt;Dj ≤ Dmaxt&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Să schimbe dragonul din specia &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt; pe care îl are cu un dragon din specia &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt; aflat pe insula respectivă.&lt;br /&gt;
&lt;br /&gt;
= Cerințe =&lt;br /&gt;
a. Să se determine distanța maxima &amp;lt;code&amp;gt;Dmaxi&amp;lt;/code&amp;gt; caracteristică unui dragon la care Hiccup poate ajunge fără a schimba dragonul pe care l-a luat inițial de pe insula &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
b. Să se determine distanța minimă pe care Hiccup trebuie să o parcurgă pentru a ajunge de pe insula &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; pe insula &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
= Date de intrare =&lt;br /&gt;
Fișierul de intrare &amp;lt;code&amp;gt;dragoniIN.txt&amp;lt;/code&amp;gt; conține pe prima linie numărul &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt;. Pentru toate testele de intrare, numărul &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; poate avea doar valoarea &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; sau valoarea &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt;. Pe a doua linie se găsesc două numere naturale &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; și &amp;lt;code&amp;gt;M&amp;lt;/code&amp;gt; reprezentând numărul de insule, respectiv numărul de rute directe între insule. Pe a treia linie se găsesc &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; numere naturale, al &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt;-lea dintre acestea reprezentând distanta maximă &amp;lt;code&amp;gt;Dmaxi&amp;lt;/code&amp;gt; pe care o poate zbura un dragon de pe insula &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt;. Pe următoarele &amp;lt;code&amp;gt;M&amp;lt;/code&amp;gt; linii sunt descrise cele &amp;lt;code&amp;gt;M&amp;lt;/code&amp;gt; rute directe. Pe fiecare dintre aceste linii se găsesc câte trei numere naturale &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;B&amp;lt;/code&amp;gt; și &amp;lt;code&amp;gt;D&amp;lt;/code&amp;gt; cu semnificația că există rută bidirecțională de lungime &amp;lt;code&amp;gt;D&amp;lt;/code&amp;gt; între insulele &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; și &amp;lt;code&amp;gt;B&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
= Date de ieșire =&lt;br /&gt;
n fișierul de ieșire &amp;lt;code&amp;gt;dragoniOUt.txt&amp;lt;/code&amp;gt; se va afișa un singur număr natural.&lt;br /&gt;
&lt;br /&gt;
Dacă valoarea lui &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; este &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;, se rezolvă numai cerința a.&lt;br /&gt;
&lt;br /&gt;
În acest caz numărul afișat va reprezenta distanța maximă &amp;lt;code&amp;gt;Dmaxi&amp;lt;/code&amp;gt; a unui dragon &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt; la care Hiccup poate ajunge fără a schimba dragonul pe care l-a luat inițial de pe insula &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Daca valoarea lui &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; este &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt;, se va rezolva numai cerința b,&lt;br /&gt;
&lt;br /&gt;
În acest caz numărul afișat va reprezenta distanța minima pe care Hiccup trebuie să o parcurgă pentru a ajunge de pe insula &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; pe insula &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;.În cazul în care restricțiile nu sunt îndeplinite, se va afișa mesajul &amp;quot;Datele nu corespund restrictiilor impuse&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
= Restricții și precizări =&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;1 ≤ N ≤ 800&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;1 ≤ M ≤ 6000&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;1 ≤ Dmaxi ≤ 50 000&amp;lt;/code&amp;gt;, pentru orice &amp;lt;code&amp;gt;1 ≤ i ≤ N&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;1 ≤ Aj, Bj ≤ N&amp;lt;/code&amp;gt;, pentru orice &amp;lt;code&amp;gt;1 ≤ j ≤ M&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;1 ≤ Dj ≤ 50 000&amp;lt;/code&amp;gt;, pentru orice &amp;lt;code&amp;gt;1 ≤ j ≤ M&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Se garantează că Hiccup poate ajunge pe insula &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Se garantează că răspunsul oricărei cerințe este un număr natural mai mic decât &amp;lt;code&amp;gt;109&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Pentru rezolvarea corectă a primei cerințe se acordă 20% din punctajul testului respectiv.&lt;br /&gt;
* Pentru rezolvarea corectă a celei de-a doua cerințe se acordă 80% din punctajul testului respectiv.&lt;br /&gt;
&lt;br /&gt;
= Exemplul 1: =&lt;br /&gt;
&amp;lt;code&amp;gt;dragoniIN.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
 1&lt;br /&gt;
 5 6&lt;br /&gt;
 6 3 13 20 26&lt;br /&gt;
 1 2 5&lt;br /&gt;
 1 3 7&lt;br /&gt;
 1 5 10&lt;br /&gt;
 2 3 6&lt;br /&gt;
 3 4 5&lt;br /&gt;
 3 5 14&lt;br /&gt;
&amp;lt;code&amp;gt;dragoniOUt.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
 20&lt;br /&gt;
&lt;br /&gt;
= Explicație =&lt;br /&gt;
&amp;lt;code&amp;gt;p = 1&amp;lt;/code&amp;gt; deci se va rezolva cerința a).&lt;br /&gt;
&lt;br /&gt;
Există &amp;lt;code&amp;gt;N = 5&amp;lt;/code&amp;gt; insule si &amp;lt;code&amp;gt;M = 6&amp;lt;/code&amp;gt; rute între ele. Hiccup pornește de pe insula &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; având un dragon care poate zbura o distanță de maxim &amp;lt;code&amp;gt;6&amp;lt;/code&amp;gt;. Cu acest dragon poate ajunge doar pe insulele &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt; si &amp;lt;code&amp;gt;4&amp;lt;/code&amp;gt;, întrucât pentru a ajunge pe insula &amp;lt;code&amp;gt;5&amp;lt;/code&amp;gt; el ar fi obligat sa parcurgă o ruta de lungime mai mare decât &amp;lt;code&amp;gt;6&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Distanta maxima pe care o poate zbura un dragon aflat pe insulele &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt; sau &amp;lt;code&amp;gt;4&amp;lt;/code&amp;gt; este deci &amp;lt;code&amp;gt;20&amp;lt;/code&amp;gt; (dragonul de pe insula &amp;lt;code&amp;gt;4&amp;lt;/code&amp;gt;). Se observă că dragonul care poate zbura o distanță de &amp;lt;code&amp;gt;26&amp;lt;/code&amp;gt; se afla pe insula 5 și este inaccesibil.&lt;br /&gt;
&lt;br /&gt;
== Exemplul 2: ==&lt;br /&gt;
&amp;lt;code&amp;gt;dragoniIN.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
 1&lt;br /&gt;
 801 6&lt;br /&gt;
 6 3 13 20 26&lt;br /&gt;
 1 2 5&lt;br /&gt;
 1 3 7&lt;br /&gt;
 1 5 10&lt;br /&gt;
 2 3 6&lt;br /&gt;
 3 4 5&lt;br /&gt;
 3 5 14&lt;br /&gt;
&amp;lt;code&amp;gt;dragoniOUt.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
 Datele nu corespund restrictiilor impuse&lt;br /&gt;
&lt;br /&gt;
== Rezolvare ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python3&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
import heapq&lt;br /&gt;
&lt;br /&gt;
class Dij:&lt;br /&gt;
    def __init__(self, nod, cost):&lt;br /&gt;
        self.nod = nod&lt;br /&gt;
        self.cost = cost&lt;br /&gt;
&lt;br /&gt;
    def __lt__(self, other):&lt;br /&gt;
        return self.cost &amp;gt; other.cost&lt;br /&gt;
&lt;br /&gt;
def validate_restrictions(n, m, dmax):&lt;br /&gt;
    if not (1 &amp;lt;= n &amp;lt;= 800 and 1 &amp;lt;= m &amp;lt;= 6000):&lt;br /&gt;
        return False&lt;br /&gt;
    &lt;br /&gt;
    for i in range(1, n + 1):&lt;br /&gt;
        if not (1 &amp;lt;= dmax[i] &amp;lt;= 50000):&lt;br /&gt;
            return False&lt;br /&gt;
    &lt;br /&gt;
    return True&lt;br /&gt;
&lt;br /&gt;
with open(&amp;quot;dragoniIN.txt&amp;quot;, &amp;quot;r&amp;quot;) as fin, open(&amp;quot;dragoniOUT.txt&amp;quot;, &amp;quot;w&amp;quot;) as fout:&lt;br /&gt;
    p = int(fin.readline())&lt;br /&gt;
    &lt;br /&gt;
    if p == 1:&lt;br /&gt;
        n, m = map(int, fin.readline().split())&lt;br /&gt;
        dmax = [0] + list(map(int, fin.readline().split()))&lt;br /&gt;
&lt;br /&gt;
        if not validate_restrictions(n, m, dmax):&lt;br /&gt;
            fout.write(&amp;quot;Datele nu corespund restrictiilor impuse\n&amp;quot;)&lt;br /&gt;
            exit()&lt;br /&gt;
&lt;br /&gt;
        gf = [[] for _ in range(n + 1)]&lt;br /&gt;
&lt;br /&gt;
        for _ in range(m):&lt;br /&gt;
            a, b, c = map(int, fin.readline().split())&lt;br /&gt;
            if not (1 &amp;lt;= a &amp;lt;= n and 1 &amp;lt;= b &amp;lt;= n and 1 &amp;lt;= c &amp;lt;= 50000):&lt;br /&gt;
                fout.write(&amp;quot;Datele nu corespund restrictiilor impuse\n&amp;quot;)&lt;br /&gt;
                exit()&lt;br /&gt;
            gf[a].append((b, c))&lt;br /&gt;
            gf[b].append((a, c))&lt;br /&gt;
&lt;br /&gt;
        q = []&lt;br /&gt;
        max_val = dmax[1]&lt;br /&gt;
        viz = [False] * (n + 1)&lt;br /&gt;
        viz[1] = True&lt;br /&gt;
        q.append(1)&lt;br /&gt;
&lt;br /&gt;
        while q:&lt;br /&gt;
            nod = q.pop(0)&lt;br /&gt;
&lt;br /&gt;
            for nex in gf[nod]:&lt;br /&gt;
                if nex[1] &amp;lt;= dmax[1] and not viz[nex[0]]:&lt;br /&gt;
                    viz[nex[0]] = True&lt;br /&gt;
                    max_val = max(max_val, dmax[nex[0]])&lt;br /&gt;
                    q.append(nex[0])&lt;br /&gt;
&lt;br /&gt;
        fout.write(str(max_val) + &amp;quot;\n&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    elif p == 2:&lt;br /&gt;
        n, m = map(int, fin.readline().split())&lt;br /&gt;
        dmax = [0] + list(map(int, fin.readline().split()))&lt;br /&gt;
&lt;br /&gt;
        if not validate_restrictions(n, m, dmax):&lt;br /&gt;
            fout.write(&amp;quot;Datele nu corespund restrictiilor impuse\n&amp;quot;)&lt;br /&gt;
            exit()&lt;br /&gt;
&lt;br /&gt;
        cost = [[float(&amp;#039;inf&amp;#039;)] * (n + 1) for _ in range(n + 1)]&lt;br /&gt;
        costmin = [[float(&amp;#039;inf&amp;#039;)] * (n + 1) for _ in range(n + 1)]&lt;br /&gt;
        gf = [[] for _ in range(n + 1)]&lt;br /&gt;
&lt;br /&gt;
        for _ in range(m):&lt;br /&gt;
            a, b, c = map(int, fin.readline().split())&lt;br /&gt;
            if not (1 &amp;lt;= a &amp;lt;= n and 1 &amp;lt;= b &amp;lt;= n and 1 &amp;lt;= c &amp;lt;= 50000):&lt;br /&gt;
                fout.write(&amp;quot;Datele nu corespund restrictiilor impuse\n&amp;quot;)&lt;br /&gt;
                exit()&lt;br /&gt;
            gf[a].append((b, c))&lt;br /&gt;
            gf[b].append((a, c))&lt;br /&gt;
&lt;br /&gt;
        for i in range(1, n + 1):&lt;br /&gt;
            pq = []&lt;br /&gt;
            heapq.heappush(pq, Dij(i, 0))&lt;br /&gt;
            cost[i][i] = 0&lt;br /&gt;
&lt;br /&gt;
            while pq:&lt;br /&gt;
                cur = heapq.heappop(pq)&lt;br /&gt;
                nod, costc = cur.nod, cur.cost&lt;br /&gt;
&lt;br /&gt;
                if costc &amp;lt; cost[i][nod]:&lt;br /&gt;
                    continue&lt;br /&gt;
&lt;br /&gt;
                for nex in gf[nod]:&lt;br /&gt;
                    if nex[1] &amp;lt;= dmax[i] and costc + nex[1] &amp;lt; cost[i][nex[0]]:&lt;br /&gt;
                        cost[i][nex[0]] = costc + nex[1]&lt;br /&gt;
                        heapq.heappush(pq, Dij(nex[0], cost[i][nex[0]]))&lt;br /&gt;
&lt;br /&gt;
        class Stare:&lt;br /&gt;
            def __init__(self, nod, cost, dragon):&lt;br /&gt;
                self.nod = nod&lt;br /&gt;
                self.cost = cost&lt;br /&gt;
                self.dragon = dragon&lt;br /&gt;
&lt;br /&gt;
        q = []&lt;br /&gt;
        q.append(Stare(1, 0, 1))&lt;br /&gt;
        costfinalmin = float(&amp;#039;inf&amp;#039;)&lt;br /&gt;
        costmin[1][1] = 0&lt;br /&gt;
&lt;br /&gt;
        while q:&lt;br /&gt;
            cur = q.pop(0)&lt;br /&gt;
            nod, costc, dragon = cur.nod, cur.cost, cur.dragon&lt;br /&gt;
&lt;br /&gt;
            if costc &amp;gt; costmin[dragon][nod]:&lt;br /&gt;
                continue&lt;br /&gt;
&lt;br /&gt;
            for nex in gf[nod]:&lt;br /&gt;
                if nex[1] &amp;lt;= dmax[dragon]:&lt;br /&gt;
                    nexcost = costc + nex[1]&lt;br /&gt;
                    nexdrag = dragon&lt;br /&gt;
                    if dmax[nex[0]] &amp;gt; dmax[dragon]:&lt;br /&gt;
                        nexdrag = nex[0]&lt;br /&gt;
                    elif dmax[nex[0]] == dmax[dragon]:&lt;br /&gt;
                        nexdrag = min(dragon, nex[0])&lt;br /&gt;
&lt;br /&gt;
                    if nexcost &amp;gt;= costmin[nexdrag][nex[0]]:&lt;br /&gt;
                        continue&lt;br /&gt;
&lt;br /&gt;
                    costmin[nexdrag][nex[0]] = nexcost&lt;br /&gt;
                    q.append(Stare(nex[0], nexcost, nexdrag))&lt;br /&gt;
&lt;br /&gt;
                    costfinalmin = min(costfinalmin, costmin[nexdrag][nex[0]] + cost[nexdrag][nex[0]])&lt;br /&gt;
&lt;br /&gt;
        fout.write(str(costfinalmin) + &amp;quot;\n&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rus Marius</name></author>
	</entry>
</feed>