Rezultati

Up. imeNalogaJezikRezultatČas oddaje
sts-koper-2019 Moderna umetnost Java 100/100OK 09. maj '19 @ 19:52

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 20/20 37,473 MiB 0,000 s OK
#2 [več] 20/20 40,344 MiB 0,000 s OK
#3 [več] 20/20 44,117 MiB 0,000 s OK
#4 [več] 20/20 41,313 MiB 0,000 s OK
#5 [več] 20/20 44,098 MiB 0,000 s OK

Ocenjevani program (ModernArt.java):
import java.io.*;

public class ModernArt {
	
	/**
	 * Reads input at console.
	 */
	public static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	
	// Data variables: //
	public static String data[];
	public static int w, h, n;
	public static int x1, y1, x2, y2;
	public static int shade[][];
	public static int m = 0;
	// End of data variables. //
	
	/**
	 * Reading of the input data.
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		data = reader.readLine().split(" ");
		w = Integer.parseInt(data[0]); h = Integer.parseInt(data[1]); n = Integer.parseInt(data[2]);
		shade = new int[w][h];
		for (int i = 0; i < n; i++) {
			data = reader.readLine().split(" ");
			boolean inside = false;
			x1 = Integer.parseInt(data[0]); y1 = Integer.parseInt(data[1]);
			x2 = Integer.parseInt(data[2]); y2 = Integer.parseInt(data[3]);
			for (int j = (Math.min(y1, y2) > 1) ? Math.min(y1, y2) : 1; j <= h && j <= Math.max(y1, y2); j++) {
				for (int k = (Math.min(x1, x2) > 1) ? Math.min(x1, x2) : 1; k <= w && k <= Math.max(x1, x2); k++) {
					if (k > 0 && j > 0 && k <= shade.length && j <= shade[k-1].length) {
						shade[k-1][j-1]++;
						inside = true;
					}
				}
			}
			if (inside) m++;
		}
		solve();
		reader.close();
	}
	
	/**
	 * Solves the problem and prints the result.
	 */
	public static void solve() {
		System.out.print("+"); for (int i = 0; i < w; i++) System.out.print("-"); System.out.print("+\n");
		for (int i = 0; i < h; i++) {
			System.out.print("|");
			for (int j = 0; j < w; j++) {
				if (shade[j][i] == 1) System.out.print(".");
				else if (shade[j][i] == 2) System.out.print(":");
				else if (shade[j][i] == 3) System.out.print("-");
				else if (shade[j][i] == 4) System.out.print("=");
				else if (shade[j][i] == 5) System.out.print("+");
				else if (shade[j][i] == 6) System.out.print("*");
				else if (shade[j][i] == 7) System.out.print("$");
				else if (shade[j][i] == 8) System.out.print("#");
				else if (shade[j][i] == 9) System.out.print("%");
				else if (shade[j][i] >= 10) System.out.print("@");
				else  System.out.print(" ");
			}
			System.out.print("|\n");
		}
		System.out.print("+"); for (int i = 0; i < w; i++) System.out.print("-"); System.out.print("+\n");
		System.out.println(m + " pravokotnikov na belem");
	}
	
}

//===== Input: =====//
/*
20 10 5
1 10 5 7
-5 8 30 8
3 8 3 8
-10 50 -20 40
2 9 9 3
*/

//===== Output: =====//
/*
+--------------------+
|                    |
|                    |
| ........           |
| ........           |
| ........           |
| ........           |
|.::::....           |
|:-=--::::...........|
|.::::....           |
|.....               |
+--------------------+
13 pravokotnikov na belem
*/