Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 20/20 41,063 MiB 0,000 s OK
#2 [več] 20/20 46,520 MiB 0,167 s OK
#3 [več] 20/20 50,074 MiB 0,056 s OK
#4 [več] 20/20 44,934 MiB 0,000 s OK
#5 [več] 20/20 45,137 MiB 0,066 s OK

Ocenjevani program (moderna2.java):
import java.util.*;

public class moderna2 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int w = sc.nextInt();
		int h = sc.nextInt();
		int n = sc.nextInt();
		int m = 0;
		
		int[][] platno = new int[w][h];
		char[] znaki = {' ', '.', ':', '-', '=', '+', '*', '$', '#', '%', '@'};
		
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int d = sc.nextInt();
			
			/*System.out.print("+");
			for (int k = 0; k < w; k++) {
				System.out.print("-");
			}
			System.out.println("+");
			
			for (int k = 0; k < h; k++) {
				System.out.print("|");
				for (int j = 0; j < w; j++) {
					System.out.print(znaki[platno[j][k]]);
				}
				System.out.println("|");
			}
			
			System.out.print("+");
			for (int k = 0; k < w; k++) {
				System.out.print("-");
			}
			System.out.println("+");*/
			
			if (a > c) {
				int temp = a;
				a = c;
				c = temp;
			}
			
			if (b < d) {
				int temp = b;
				b = d;
				d = temp;
			}
			
			int xL, xD, yS, yZ;
			
			if (a < 1) {
				if (c >= 1) {
					xL = 1;
					xD = Math.min(c, w);
				}
				
				else continue;
				
				if (d < 1) {
					if (b >= 1) {
						m++;
						yZ = 1;
						yS = Math.min(b, h);
						
						for (int k = xL; k <= xD; k++) {
							for (int j =  yZ; j <= yS; j++) {
								if (platno [k-1][j-1]!=10) platno[k-1][j-1]++;
							}
						}
					}
					
					else continue;
				}
				
				else if (d <= h) {
					m++;
					yZ = d;
					yS = Math.min(b, h);
					
					for (int k = xL; k <= xD; k++) {
						for (int j =  yZ; j <= yS; j++) {
							if (platno [k-1][j-1]!=10) platno[k-1][j-1]++;
						}
					}
				}
			}
			
			else if (a <= w) {
				xL = a;
				xD = Math.min(c, w);
				
				if (d < 1) {
					if (b >= 1) {
						m++;
						yZ = 1;
						yS = Math.min(b, h);
						
						for (int k = xL; k <= xD; k++) {
							for (int j =  yZ; j <= yS; j++) {
								if (platno [k-1][j-1]!=10) platno[k-1][j-1]++;
							}
						}
					}
					
					else continue;
				}
				
				else if (d <= h) {
					m++;
					yZ = d;
					yS = Math.min(b, h);
					
					for (int k = xL; k <= xD; k++) {
						for (int j =  yZ; j <= yS; j++) {
							if (platno [k-1][j-1]!=10) platno[k-1][j-1]++;
						}
					}
				}
			}
		}
		
		System.out.print("+");
		for (int i = 0; i < w; i++) {
			System.out.print("-");
		}
		System.out.println("+");
		
		for (int i = 0; i < h; i++) {
			System.out.print("|");
			for (int j = 0; j < w; j++) {
				System.out.print(znaki[platno[j][i]]);
			}
			System.out.println("|");
		}
		
		System.out.print("+");
		for (int i = 0; i < w; i++) {
			System.out.print("-");
		}
		System.out.println("+");
		
		System.out.println(m+" pravokotnikov na belem");

	}

}