Rezultati

Up. imeNalogaJezikRezultatČas oddaje
scoreoutofboundsexception-2019 Moderna umetnost Java 100/100OK 09. maj '19 @ 16:51

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 20/20 35,070 MiB 0,000 s OK
#2 [več] 20/20 38,563 MiB 0,000 s OK
#3 [več] 20/20 37,902 MiB 0,000 s OK
#4 [več] 20/20 38,332 MiB 0,000 s OK
#5 [več] 20/20 38,410 MiB 0,000 s OK

Ocenjevani program (pica.java):
import java.io.*;
import java.util.*;

public class pica {
	static PrintWriter out = new PrintWriter(System.out);

	public static void print(int[][] q) {
		String s = " .:-=+*$#%@";
		int w = q[0].length;
		int h = q.length;
		out.print("+");
		for (int i = 0; i < w; i++) {
			out.print("-");
		}
		out.println("+");
		for (int[] c : q) {
			out.print("|");
			for (int d : c) {
				if (d > 10) {
					d = 10;
				}
				out.print(s.charAt(d));
			}
			out.print("|");
			out.println();
		}
		out.print("+");
		for (int i = 0; i < w; i++) {
			out.print("-");
		}
		out.println("+");
	}

	public static void main(String[] args) throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(in.readLine());
		int w = Integer.parseInt(st.nextToken());
		int h = Integer.parseInt(st.nextToken());
		int n = Integer.parseInt(st.nextToken());
		int[][] q = new int[h][w];
		int count = 0;
		for (int i = 0; i < n; i++) {
			st = new StringTokenizer(in.readLine());
			int x1 = Integer.parseInt(st.nextToken()) - 1;
			int y1 = Integer.parseInt(st.nextToken()) - 1;
			int x2 = Integer.parseInt(st.nextToken()) - 1;
			int y2 = Integer.parseInt(st.nextToken()) - 1;
			int mx = Math.min(x1, x2);
			int Mx = Math.max(x1, x2);
			int my = Math.min(y1, y2);
			int My = Math.max(y1, y2);
			if (Mx < 0 || mx >= w || My < 0 || my >= h) {
				continue;
			} else {
				count++;
			}
			if (mx < -105) {
				mx = -105;
			}
			if (Mx > 105) {
				Mx = 105;
			}
			if (my < -105) {
				my = -105;
			}
			if (My > 105) {
				My = 105;
			}
			for (int px = mx; px <= Mx; px++) {
				if(px<0||px>=w) {
					continue;
				}
				for (int py = my; py <= My; py++) {
					if(py<0||py>=h) {
						continue;
					}
					q[py][px]++;
				}
			}
		}
		print(q);
		out.println(count + " pravokotnikov na belem");
		out.close();
	}

}