<?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=0601_-_Dreptunghiuri</id>
	<title>0601 - Dreptunghiuri - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.universitas.ro/index.php?action=history&amp;feed=atom&amp;title=0601_-_Dreptunghiuri"/>
	<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=0601_-_Dreptunghiuri&amp;action=history"/>
	<updated>2026-05-01T04:53:13Z</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=0601_-_Dreptunghiuri&amp;diff=9005&amp;oldid=prev</id>
		<title>Corjuc Eunice: Pagină nouă: = Cerința = Se consideră într-un reper cartezian &lt;code&gt;n&lt;/code&gt; puncte cu coordonate pozitive. Prin fiecare punct se desenează o dreaptă verticală și una orizontală. Să se determine câte dreptunghiuri cu interioarele disjuncte s-au format prin intermediul acestor drepte şi al axelor de coordonate.  = Date de intrare = Fișierul de intrare &lt;code&gt;input.txt&lt;/code&gt; conține pe prima linie numărul &lt;code&gt;n&lt;/code&gt;; următoarele &lt;code&gt;n&lt;/code&gt; linii conțin câte două nu...</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=0601_-_Dreptunghiuri&amp;diff=9005&amp;oldid=prev"/>
		<updated>2024-01-04T18:36:49Z</updated>

		<summary type="html">&lt;p&gt;Pagină nouă: = Cerința = Se consideră într-un reper cartezian &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; puncte cu coordonate pozitive. Prin fiecare punct se desenează o dreaptă verticală și una orizontală. Să se determine câte dreptunghiuri cu interioarele disjuncte s-au format prin intermediul acestor drepte şi al axelor de coordonate.  = Date de intrare = Fișierul de intrare &amp;lt;code&amp;gt;input.txt&amp;lt;/code&amp;gt; conține pe prima linie numărul &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt;; următoarele &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; linii conțin câte două nu...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Cerința =&lt;br /&gt;
Se consideră într-un reper cartezian &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; puncte cu coordonate pozitive. Prin fiecare punct se desenează o dreaptă verticală și una orizontală. Să se determine câte dreptunghiuri cu interioarele disjuncte s-au format prin intermediul acestor drepte şi al axelor de coordonate.&lt;br /&gt;
&lt;br /&gt;
= Date de intrare =&lt;br /&gt;
Fișierul de intrare &amp;lt;code&amp;gt;input.txt&amp;lt;/code&amp;gt; conține pe prima linie numărul &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt;; următoarele &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; linii conțin câte două numere &amp;lt;code&amp;gt;x y&amp;lt;/code&amp;gt;, reprezentând coordonatele punctelor.&lt;br /&gt;
&lt;br /&gt;
= Date de ieșire =&lt;br /&gt;
Fișierul de ieșire &amp;lt;code&amp;gt;output.txt&amp;lt;/code&amp;gt; va conține pe prima linie numărul &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt;, reprezentând valoarea cerută.&lt;br /&gt;
&lt;br /&gt;
= Restricții și precizări =&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;1 ≤ n ≤ 1000&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Exemplul 1 ==&lt;br /&gt;
input.txt:&lt;br /&gt;
&lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
1 0&lt;br /&gt;
&lt;br /&gt;
2 4&lt;br /&gt;
&lt;br /&gt;
4 2&lt;br /&gt;
&lt;br /&gt;
1 2&lt;br /&gt;
&lt;br /&gt;
output.txt:&lt;br /&gt;
&lt;br /&gt;
6&lt;br /&gt;
&lt;br /&gt;
== Exemplul 2 ==&lt;br /&gt;
input.txt:&lt;br /&gt;
&lt;br /&gt;
9999999&lt;br /&gt;
&lt;br /&gt;
1 0&lt;br /&gt;
&lt;br /&gt;
3 4&lt;br /&gt;
&lt;br /&gt;
4 2&lt;br /&gt;
&lt;br /&gt;
1 2&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
Constrangeri neindeplinite&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;
def ver(n):&lt;br /&gt;
    if not(1&amp;lt;=n&amp;lt;=1000):&lt;br /&gt;
        print(&amp;quot;Constrangeri neindeplinite&amp;quot;)&lt;br /&gt;
        exit()&lt;br /&gt;
        &lt;br /&gt;
with open(&amp;quot;input.txt&amp;quot;, &amp;#039;r&amp;#039;) as fin, open(&amp;quot;output.txt&amp;quot;, &amp;#039;w&amp;#039;) as fout:&lt;br /&gt;
    n = int(fin.readline())&lt;br /&gt;
    ver(n)&lt;br /&gt;
    a = [0] * (n + 1)&lt;br /&gt;
    b = [0] * (n + 1)&lt;br /&gt;
&lt;br /&gt;
    for i in range(1, n + 1):&lt;br /&gt;
        a[i], b[i] = map(int, fin.readline().split())&lt;br /&gt;
&lt;br /&gt;
    for i in range(1, n):&lt;br /&gt;
        for j in range(i + 1, n + 1):&lt;br /&gt;
            if a[i] &amp;gt; a[j]:&lt;br /&gt;
                a[i], a[j] = a[j], a[i]&lt;br /&gt;
            if b[i] &amp;gt; b[j]:&lt;br /&gt;
                b[i], b[j] = b[j], b[i]&lt;br /&gt;
&lt;br /&gt;
    cnt1 = 0&lt;br /&gt;
    cnt2 = 0&lt;br /&gt;
&lt;br /&gt;
    for i in range(1, n + 1):&lt;br /&gt;
        if a[i] != a[i - 1]:&lt;br /&gt;
            cnt1 += 1&lt;br /&gt;
        if b[i] != b[i - 1]:&lt;br /&gt;
            cnt2 += 1&lt;br /&gt;
&lt;br /&gt;
    fout.write(str(cnt1 * cnt2))&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Corjuc Eunice</name></author>
	</entry>
</feed>