<?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=2902_-_Pavaj</id>
	<title>2902 - Pavaj - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.universitas.ro/index.php?action=history&amp;feed=atom&amp;title=2902_-_Pavaj"/>
	<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=2902_-_Pavaj&amp;action=history"/>
	<updated>2026-06-17T07:46:50Z</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=2902_-_Pavaj&amp;diff=8157&amp;oldid=prev</id>
		<title>Raul: Pagină nouă:  = Cerința = Curtea bunicului are forma unei matrice cu &lt;code&gt;n&lt;/code&gt; linii și &lt;code&gt;m&lt;/code&gt; coloane și este pavată cu &lt;code&gt;n*m&lt;/code&gt; dale, o parte dintre acestea fiind deteriorate. Bunicul a realizat un plan al curții în care a marcat cu &lt;code&gt;0&lt;/code&gt; dalele deteriorate și cu &lt;code&gt;1&lt;/code&gt; pe cele nedeteriorate.  Bunicul a primit &lt;code&gt;k&lt;/code&gt; oferte pentru a vinde zone dreptunghiulare ale curții. Fiecare zonă este determinată de coordonatele &lt;code&gt;l1 c1 l2...</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=2902_-_Pavaj&amp;diff=8157&amp;oldid=prev"/>
		<updated>2023-12-15T18:19:32Z</updated>

		<summary type="html">&lt;p&gt;Pagină nouă:  = Cerința = Curtea bunicului are forma unei matrice cu &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; linii și &amp;lt;code&amp;gt;m&amp;lt;/code&amp;gt; coloane și este pavată cu &amp;lt;code&amp;gt;n*m&amp;lt;/code&amp;gt; dale, o parte dintre acestea fiind deteriorate. Bunicul a realizat un plan al curții în care a marcat cu &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; dalele deteriorate și cu &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; pe cele nedeteriorate.  Bunicul a primit &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt; oferte pentru a vinde zone dreptunghiulare ale curții. Fiecare zonă este determinată de coordonatele &amp;lt;code&amp;gt;l1 c1 l2...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
= Cerința =&lt;br /&gt;
Curtea bunicului are forma unei matrice cu &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; linii și &amp;lt;code&amp;gt;m&amp;lt;/code&amp;gt; coloane și este pavată cu &amp;lt;code&amp;gt;n*m&amp;lt;/code&amp;gt; dale, o parte dintre acestea fiind deteriorate. Bunicul a realizat un plan al curții în care a marcat cu &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; dalele deteriorate și cu &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; pe cele nedeteriorate.&lt;br /&gt;
&lt;br /&gt;
Bunicul a primit &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt; oferte pentru a vinde zone dreptunghiulare ale curții. Fiecare zonă este determinată de coordonatele &amp;lt;code&amp;gt;l1 c1 l2 c2&amp;lt;/code&amp;gt; a două colțuri opuse ale ei. Pentru fiecare zonă bunicul dorește să afle dacă conține doar dale nedeteriorate, doar dale deteriorate sau conține și dale deteriorate și dale nedeteriorate.&lt;br /&gt;
&lt;br /&gt;
= Date de intrare =&lt;br /&gt;
Fișierul de intrare &amp;lt;code&amp;gt;pavaj.in&amp;lt;/code&amp;gt; conține pe prima linie numerele &amp;lt;code&amp;gt;n m k&amp;lt;/code&amp;gt;. Următoarele &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; linii conțin câte &amp;lt;code&amp;gt;m&amp;lt;/code&amp;gt; valori &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; sau &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;, reprezentând planul curții. Următoarele &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt; linii conțin câte patru valori, &amp;lt;code&amp;gt;l1 c1 l2 c2&amp;lt;/code&amp;gt;, reprezentând coordonatele a două colțuri opuse ale unei zone.&lt;br /&gt;
&lt;br /&gt;
= Date de ieșire =&lt;br /&gt;
Fișierul de ieșire &amp;lt;code&amp;gt;pavaj.out&amp;lt;/code&amp;gt; va conține &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt; linii. Fiecare linie va conține valoarea &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; sau &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt;, după cum zona corespunzătoare din fișierul de intrare:&lt;br /&gt;
&lt;br /&gt;
* conține doar dale deteriorate&lt;br /&gt;
* conține doar dale nedeteriorate&lt;br /&gt;
* conține atât dale nedeteriorate, cât și dale deteriorate&lt;br /&gt;
&lt;br /&gt;
= Restricții și precizări =&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;1 ≤ n, m ≤ 1000&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;1 ≤ k ≤ 100000&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;1 ≤ l1, l2 ≤ n&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;1 ≤ c1, c2 ≤ m&amp;lt;/code&amp;gt;&lt;br /&gt;
* numerotarea liniilor și a coloanelor începe de la &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;&lt;br /&gt;
* pentru 50% din teste &amp;lt;code&amp;gt;1 ≤ n, m, k ≤ 1000&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Exemplu: =&lt;br /&gt;
&amp;lt;code&amp;gt;pavaj.in&amp;lt;/code&amp;gt;&lt;br /&gt;
 4 6 3&lt;br /&gt;
 0 0 1 1 1 0&lt;br /&gt;
 0 0 1 1 1 0&lt;br /&gt;
 0 0 0 0 0 1&lt;br /&gt;
 1 0 1 0 1 0&lt;br /&gt;
 1 1 3 2&lt;br /&gt;
 2 4 1 5&lt;br /&gt;
 1 6 4 2&lt;br /&gt;
&amp;lt;code&amp;gt;pavaj.out&amp;lt;/code&amp;gt;&lt;br /&gt;
 0&lt;br /&gt;
 1&lt;br /&gt;
 2&lt;br /&gt;
&lt;br /&gt;
== Încărcare soluție ==&lt;br /&gt;
&lt;br /&gt;
=== Lipește codul aici ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;fstream&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    ifstream cin(&amp;quot;pavaj.in&amp;quot;);&lt;br /&gt;
    ofstream cout(&amp;quot;pavaj.out&amp;quot;);&lt;br /&gt;
    int n, m, t, s[1001][1001], i1, j1, i2, j2;&lt;br /&gt;
    cin &amp;gt;&amp;gt; n &amp;gt;&amp;gt; m &amp;gt;&amp;gt; t;&lt;br /&gt;
    for (int i = 1; i &amp;lt;= n; i++)&lt;br /&gt;
        for (int j = 1; j &amp;lt;= m; j++)&lt;br /&gt;
            cin &amp;gt;&amp;gt; s[i][j];&lt;br /&gt;
    for (int i = 1; i &amp;lt;= n; ++i)&lt;br /&gt;
        for (int j = 1; j &amp;lt;= m; ++j)&lt;br /&gt;
            s[i][j] = s[i][j] + s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];&lt;br /&gt;
    for (int i = 1; i &amp;lt;= t; i++)&lt;br /&gt;
    {&lt;br /&gt;
        cin &amp;gt;&amp;gt; i1 &amp;gt;&amp;gt; j1 &amp;gt;&amp;gt; i2 &amp;gt;&amp;gt; j2;&lt;br /&gt;
        int sum = 0, nr = 0;&lt;br /&gt;
        if (i1 &amp;lt;= i2 &amp;amp;&amp;amp; j1 &amp;lt;= j2)&lt;br /&gt;
            sum = s[i2][j2] - s[i1 - 1][j2] - s[i2][j1 - 1] + s[i1 - 1][j1 - 1], nr = (j2 - j1 + 1) * (i2 - i1 + 1);&lt;br /&gt;
        else if (i1 &amp;gt;= i2 &amp;amp;&amp;amp; j1 &amp;lt;= j2)&lt;br /&gt;
            sum = s[i1][j2] - s[i2 - 1][j2] - s[i1][j1 - 1] + s[i2 - 1][j1 - 1], nr = (i1 - i2 + 1) * (j2 - j1 + 1);&lt;br /&gt;
        else if (i1 &amp;lt;= i2 &amp;amp;&amp;amp; j1 &amp;gt;= j2)&lt;br /&gt;
            sum = s[i2][j1] - s[i1 - 1][j1] - s[i2][j2 - 1] + s[i1 - 1][j2 - 1], nr = (i2 - i1 + 1) * (j1 - j2 + 1);&lt;br /&gt;
        else&lt;br /&gt;
            sum = s[i1][j1] - s[i2 - 1][j1] - s[i1][j2 - 1] + s[i2 - 1][j2 - 1], nr = (i1 - i2 + 1) * (j1 - j2 + 1);&lt;br /&gt;
        if (sum == 0)&lt;br /&gt;
            cout &amp;lt;&amp;lt; 0 &amp;lt;&amp;lt; &amp;#039;\n&amp;#039;;&lt;br /&gt;
        else if (sum == nr)&lt;br /&gt;
            cout &amp;lt;&amp;lt; 1 &amp;lt;&amp;lt; &amp;#039;\n&amp;#039;;&lt;br /&gt;
        else&lt;br /&gt;
            cout &amp;lt;&amp;lt; 2 &amp;lt;&amp;lt; &amp;#039;\n&amp;#039;;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Raul</name></author>
	</entry>
</feed>