Rezultati

Up. imeNalogaJezikRezultatČas oddaje
ayy-banananjam-2019 Moderna umetnost C++ 100/100OK 09. maj '19 @ 18:10

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 20/20 3,043 MiB 0,000 s OK
#2 [več] 20/20 3,043 MiB 0,001 s OK
#3 [več] 20/20 3,043 MiB 0,001 s OK
#4 [več] 20/20 3,125 MiB 0,000 s OK
#5 [več] 20/20 3,133 MiB 0,020 s OK

Ocenjevani program (moderna_um.cpp):
#include <iostream>
#include <string>
#include <vector>

using namespace std;

struct kvadrat {
	int x1, y1, x2, y2;
};


int main()
{
	int w, h, n, n_ayy = 0;
	cin >> w >> h >> n;
	string banana = " .:-=+*$#%@";
	vector<kvadrat> njam(n);
	for (int i = 0; i < njam.size(); i++) {
		cin >> njam[i].x1 >> njam[i].y1 >> njam[i].x2 >> njam[i].y2;
		if (njam[i].x1 >= njam[i].x2) {
			njam[i].x1 = njam[i].x1 + njam[i].x2;
			njam[i].x2 = njam[i].x1 - njam[i].x2;
			njam[i].x1 = njam[i].x1 - njam[i].x2;
		}
		if (njam[i].y1 >= njam[i].y2) {
			njam[i].y1 = njam[i].y1 + njam[i].y2;
			njam[i].y2 = njam[i].y1 - njam[i].y2;
			njam[i].y1 = njam[i].y1 - njam[i].y2;
		}
		if (njam[i].y2 >= 1 && njam[i].y1 <= h) {
			if (njam[i].x2 >= 1 && njam[i].x1 <= w) {
				n_ayy++;
			}
		}
	}

	int stevec = 0;
	cout << "+";
	for (int z = 0; z < w; z++)
		cout << "-";
	cout << "+" << endl;
	for (int visina = 1; visina < h+1; visina++) {
		cout << "|";
		for (int sirina = 1; sirina < w+1; sirina++) {
			for (int l = 0; l < njam.size(); l++) {
				if (visina >= njam[l].y1 && visina <= njam[l].y2) {
					if (sirina >= njam[l].x1 && sirina <= njam[l].x2) {
						stevec++;
					}
				}
			}
			if (stevec > 10)
				stevec = 10;
			cout << banana[stevec];
			stevec = 0;
		}
		cout << "|" << endl;
	}

	cout << "+";
	for (int z = 0; z < w; z++)
		cout << "-";
	cout << "+" << endl;

	cout << n_ayy << " pravokotnikov na belem" << endl;
	return 0;
}