<?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=0963_-_Bazine</id>
	<title>0963 - Bazine - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.universitas.ro/index.php?action=history&amp;feed=atom&amp;title=0963_-_Bazine"/>
	<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=0963_-_Bazine&amp;action=history"/>
	<updated>2026-05-02T02:18:42Z</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=0963_-_Bazine&amp;diff=9176&amp;oldid=prev</id>
		<title>Simina at 12:58, 7 January 2024</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=0963_-_Bazine&amp;diff=9176&amp;oldid=prev"/>
		<updated>2024-01-07T12:58:17Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 12:58, 7 January 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l24&quot;&gt;Line 24:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 24:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Exemplul 1 =&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Exemplul 1 =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;code&amp;gt;bazineIN.txt&amp;lt;/code&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;code&amp;gt;bazineIN.txt&amp;lt;/code&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;5 &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;10 8&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  1 6&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  1 6&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  4 5&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  4 5&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Simina</name></author>
	</entry>
	<entry>
		<id>https://wiki.universitas.ro/index.php?title=0963_-_Bazine&amp;diff=7988&amp;oldid=prev</id>
		<title>Simina: Pagină nouă: == Enunț == La ştrandul Junior din oraşul nostru s-au construit &lt;code&gt;n&lt;/code&gt; bazine pentru înot. Fiecare bazin a fost dotat cu câte un robinet pentru umplerea acestuia cu apă. Între &lt;code&gt;m&lt;/code&gt; perechi distincte de bazine, a fost instalată câte o ţeavă prin care apa din cele două bazine din fiecare pereche să poată circula. Astfel, cele două bazine din pereche pot fi umplute prin deschiderea unui singur robinet.  Administratorul bazei a numerotat bazinele...</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=0963_-_Bazine&amp;diff=7988&amp;oldid=prev"/>
		<updated>2023-12-13T13:06:01Z</updated>

		<summary type="html">&lt;p&gt;Pagină nouă: == Enunț == La ştrandul Junior din oraşul nostru s-au construit &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; bazine pentru înot. Fiecare bazin a fost dotat cu câte un robinet pentru umplerea acestuia cu apă. Între &amp;lt;code&amp;gt;m&amp;lt;/code&amp;gt; perechi distincte de bazine, a fost instalată câte o ţeavă prin care apa din cele două bazine din fiecare pereche să poată circula. Astfel, cele două bazine din pereche pot fi umplute prin deschiderea unui singur robinet.  Administratorul bazei a numerotat bazinele...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Enunț ==&lt;br /&gt;
La ştrandul Junior din oraşul nostru s-au construit &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; bazine pentru înot. Fiecare bazin a fost dotat cu câte un robinet pentru umplerea acestuia cu apă. Între &amp;lt;code&amp;gt;m&amp;lt;/code&amp;gt; perechi distincte de bazine, a fost instalată câte o ţeavă prin care apa din cele două bazine din fiecare pereche să poată circula. Astfel, cele două bazine din pereche pot fi umplute prin deschiderea unui singur robinet.&lt;br /&gt;
&lt;br /&gt;
Administratorul bazei a numerotat bazinele cu numerele distincte de la &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; la &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; şi a notat în registrul lui cele &amp;lt;code&amp;gt;m&amp;lt;/code&amp;gt; perechi de numere &amp;lt;code&amp;gt;(x1,y1)&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;(x2,y2)&amp;lt;/code&amp;gt;,…., &amp;lt;code&amp;gt;(xm,ym)&amp;lt;/code&amp;gt; corespunzând perechilor de bazine între care a fost instalată câte o ţeavă. Pentru a umple toate bazinele cu apă, administratorul doreşte să deschidă un număr minim de robinete.&lt;br /&gt;
&lt;br /&gt;
Cerinţă.&lt;br /&gt;
&lt;br /&gt;
Scrieţi un program care să citească numerele naturale &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; şi &amp;lt;code&amp;gt;m&amp;lt;/code&amp;gt;, şi cele &amp;lt;code&amp;gt;2*m&amp;lt;/code&amp;gt; numere naturale &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;y1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;x2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;y2&amp;lt;/code&amp;gt;,…., &amp;lt;code&amp;gt;xm&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ym&amp;lt;/code&amp;gt;, cu semnificația din enunț, şi care să afişeze cel mai mic număr &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt; de robinete pe care trebuie să le deschidă administratorul astfel încât să fie umplute cu apă toate bazinele.&lt;br /&gt;
&lt;br /&gt;
= Date de intrare =&lt;br /&gt;
Fișierul de intrare &amp;lt;code&amp;gt;bazineIN.txt&amp;lt;/code&amp;gt; conține pe prima linie numerele &amp;lt;code&amp;gt;n m&amp;lt;/code&amp;gt;, iar pe următoarele &amp;lt;code&amp;gt;m&amp;lt;/code&amp;gt; linii căte o pereche de numere &amp;lt;code&amp;gt;x y&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
= Date de ieșire =&lt;br /&gt;
Fișierul de ieșire &amp;lt;code&amp;gt;bazineOUT.txt&amp;lt;/code&amp;gt; va conține pe prima linie numărul &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt; determinat.&lt;br /&gt;
&lt;br /&gt;
= Restricții și precizări =&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;10 ≤ n ≤ 100&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;8 ≤ m ≤ 400&amp;lt;/code&amp;gt;&lt;br /&gt;
* nu există două perechi de numere &amp;lt;code&amp;gt;(x,y)&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;(x’,y’)&amp;lt;/code&amp;gt; astfel încât &amp;lt;code&amp;gt;x=x’&amp;lt;/code&amp;gt; şi &amp;lt;code&amp;gt;y=y’&amp;lt;/code&amp;gt; sau &amp;lt;code&amp;gt;x=y’&amp;lt;/code&amp;gt; şi &amp;lt;code&amp;gt;y=x’&amp;lt;/code&amp;gt; printre cele &amp;lt;code&amp;gt;m&amp;lt;/code&amp;gt; perechi citite din fişier&lt;br /&gt;
* &amp;lt;code&amp;gt;1 ≤ xi ≤ n&amp;lt;/code&amp;gt; , &amp;lt;code&amp;gt;1 ≤ yi ≤ n&amp;lt;/code&amp;gt; , &amp;lt;code&amp;gt;xi ≠ yi&amp;lt;/code&amp;gt;&lt;br /&gt;
* fiecare bazin poate fi cuplat la unul sau mai multe bazine prin câte o ţeavă, sau la nici un bazin&lt;br /&gt;
&lt;br /&gt;
= Exemplul 1 =&lt;br /&gt;
&amp;lt;code&amp;gt;bazineIN.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
 5 &lt;br /&gt;
 1 6&lt;br /&gt;
 4 5&lt;br /&gt;
 8 6&lt;br /&gt;
 3 7&lt;br /&gt;
 9 4&lt;br /&gt;
 1 8&lt;br /&gt;
 10 6&lt;br /&gt;
 1 10&lt;br /&gt;
&amp;lt;code&amp;gt;bazineOUT.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
 4&lt;br /&gt;
&lt;br /&gt;
= Explicație =&lt;br /&gt;
Apa din bazinele &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;6&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;8&amp;lt;/code&amp;gt; şi &amp;lt;code&amp;gt;10&amp;lt;/code&amp;gt; comunică doar între acestea, fiind instalate ţevi. Astfel pentru aceste patru bazine este necesar să se deschidă un singur robinet pentru umplerea lor.&lt;br /&gt;
&lt;br /&gt;
Apa din bazinele &amp;lt;code&amp;gt;4&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;5&amp;lt;/code&amp;gt; şi &amp;lt;code&amp;gt;9&amp;lt;/code&amp;gt; comunică, deoarece între acestea sunt ţevi. Astfel pentru aceste bazine este necesar să se deschidă un singur robinet.&lt;br /&gt;
&lt;br /&gt;
Pentru bazinele &amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt; şi &amp;lt;code&amp;gt;7&amp;lt;/code&amp;gt; între care există teavă, se deschide un singur robinet, cele două bazine nefiind legate prin ţevi de celelalte bazine&lt;br /&gt;
&lt;br /&gt;
Bazinul &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; nu este cuplat cu niciun alt bazin, fiind necesar să se deschidă robinetul acestuia.&lt;br /&gt;
&lt;br /&gt;
În total se deschid doar &amp;lt;code&amp;gt;4&amp;lt;/code&amp;gt; robinete pentru a alimenta toate bazinele&lt;br /&gt;
&lt;br /&gt;
== Exemplul 2 ==&lt;br /&gt;
&amp;lt;code&amp;gt;bazineIN.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
 5 5&lt;br /&gt;
&amp;lt;code&amp;gt;bazineOUT.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
 Datele nu corespund restrictiilor impuse&lt;br /&gt;
Rezolvare&amp;lt;syntaxhighlight lang=&amp;quot;python3&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
class Graf:&lt;br /&gt;
    def __init__(self, varfuri):&lt;br /&gt;
        self.varfuri = varfuri&lt;br /&gt;
        self.lista_adiacenta = {i: [] for i in range(1, varfuri + 1)}&lt;br /&gt;
&lt;br /&gt;
    def adauga_muchie(self, u, v):&lt;br /&gt;
        self.lista_adiacenta[u].append(v)&lt;br /&gt;
        self.lista_adiacenta[v].append(u)&lt;br /&gt;
&lt;br /&gt;
    def numar_minim_robinete(self):&lt;br /&gt;
        vizitate = set()&lt;br /&gt;
        robinete = 0&lt;br /&gt;
&lt;br /&gt;
        for varf in range(1, self.varfuri + 1):&lt;br /&gt;
            if varf not in vizitate:&lt;br /&gt;
                robinete += 1&lt;br /&gt;
                self.dfs(varf, vizitate)&lt;br /&gt;
&lt;br /&gt;
        return robinete&lt;br /&gt;
&lt;br /&gt;
    def dfs(self, varf, vizitate):&lt;br /&gt;
        vizitate.add(varf)&lt;br /&gt;
        for vecin in self.lista_adiacenta[varf]:&lt;br /&gt;
            if vecin not in vizitate:&lt;br /&gt;
                self.dfs(vecin, vizitate)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def verifica_restrictii(n, m, perechi):&lt;br /&gt;
    if not(10 &amp;lt;= n &amp;lt;= 100) or not(8 &amp;lt;= m &amp;lt;= 400):&lt;br /&gt;
        return False&lt;br /&gt;
&lt;br /&gt;
    for i in range(m):&lt;br /&gt;
        x, y = perechi[i]&lt;br /&gt;
        if not(1 &amp;lt;= x &amp;lt;= n) or not(1 &amp;lt;= y &amp;lt;= n) or x == y:&lt;br /&gt;
            return False&lt;br /&gt;
&lt;br /&gt;
    for i in range(m):&lt;br /&gt;
        for j in range(i + 1, m):&lt;br /&gt;
            if set(perechi[i]) == set(perechi[j]):&lt;br /&gt;
                return False&lt;br /&gt;
&lt;br /&gt;
    return True&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    with open(&amp;quot;bazineIN.txt&amp;quot;, &amp;quot;r&amp;quot;) as fisier_intrare:&lt;br /&gt;
        n, m = map(int, fisier_intrare.readline().split())&lt;br /&gt;
        perechi = [tuple(map(int, fisier_intrare.readline().split())) for _ in range(m)]&lt;br /&gt;
&lt;br /&gt;
        if not verifica_restrictii(n, m, perechi):&lt;br /&gt;
            with open(&amp;quot;bazineOUT.txt&amp;quot;, &amp;quot;w&amp;quot;) as fisier_iesire:&lt;br /&gt;
                fisier_iesire.write(&amp;quot;Datele nu corespund restrictiilor impuse&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            graf = Graf(n)&lt;br /&gt;
&lt;br /&gt;
            for x, y in perechi:&lt;br /&gt;
                graf.adauga_muchie(x, y)&lt;br /&gt;
&lt;br /&gt;
            with open(&amp;quot;bazineOUT.txt&amp;quot;, &amp;quot;w&amp;quot;) as fisier_iesire:&lt;br /&gt;
                k = graf.numar_minim_robinete()&lt;br /&gt;
                fisier_iesire.write(str(k))&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Simina</name></author>
	</entry>
</feed>