Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 20/20 35,277 MiB 0,000 s OK
#2 [več] 20/20 35,176 MiB 0,000 s OK
#3 [več] 20/20 38,492 MiB 0,000 s OK
#4 [več] 20/20 37,758 MiB 0,000 s OK
#5 [več] 20/20 38,832 MiB 0,000 s OK

Ocenjevani program (modernaUmetnost.java):
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class modernaUmetnost {
	
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public static void main(String[] args) throws IOException {
		String prva = br.readLine();
		
		String[] prvaarr = prva.split(" ");
		int w = Integer.parseInt(prvaarr[0]);
		int h = Integer.parseInt(prvaarr[1]);
		int n = Integer.parseInt(prvaarr[2]);
		int[][] slika = new int[w][h];
		int counter = 0;
		boolean flag = false;
		
		for (int i = 0; i < n; i++) {
			String[] line = br.readLine().split(" ");
			int a1 = Integer.parseInt(line[0]) - 1;
			int a2 = Integer.parseInt(line[1]) - 1;
			int b1 = Integer.parseInt(line[2]) - 1;
			int b2 = Integer.parseInt(line[3]) - 1;
			
			
			int tmpA1 = a1;
			int tmpA2 = a2;
			int tmpB1 = b1;
			int tmpB2 = b2;
			
			a1 = Math.min(tmpA1, tmpB1);
			b1 = Math.max(tmpA2, tmpB2);
			
			a2 = Math.max(tmpA1, tmpB1);
			b2 = Math.min(tmpA2, tmpB2);

			
			
			
			
			if (a1 < 0 ) a1 = 0;
			if( a1 >= w) continue;
			
			if (a2 < 0 ) continue;
			if( a2 >= w) a2=w-1;
			
			if (b1 < 0 ) continue;
			if( b1 >= h) b1 = h-1; //w-1??
			
			if (b2 < 0 ) b2 = 0;
			if( b2 >= h) continue;
			
			//System.out.println(a1 + " " + b1 + " " + a2 + " " + b2);
			
			for (int j = a1; j <= a2; j++) {
				for(int k = b2; k <= b1; k++) {
					if (flag == false) {
						counter++;
					}
					flag = true;
					slika[j][k]++;
				}
			}
			flag = false;
			

		}
		
		StringBuilder sb = new StringBuilder();
		sb.append("+");
		for (int i = 0; i < w; i++) {
			sb.append("-");
		}
		sb.append("+");
		sb.append("\n");
		for (int j = 0; j < h; j++) {
			sb.append("|");
			for(int k = 0; k < w; k++) {
				switch(slika[k][j]) {
				case 0: sb.append(" ");
				break;
				case 1: sb.append(".");
				break;
				case 2: sb.append(":");
				break;
				case 3: sb.append("-");
				break;
				case 4: sb.append("=");
				break;
				case 5: sb.append("+");
				break;
				case 6: sb.append("*");
				break;
				case 7: sb.append("$");
				break;
				case 8: sb.append("#");
				break;
				case 9: sb.append("%");
				break;
				default: sb.append("@");
				}
				
			}
			sb.append("|\n");

		}
		sb.append("+");
		for (int i = 0; i < w; i++) {
			sb.append("-");
		}
		sb.append("+");
		
		System.out.println(sb);
		System.out.println(counter + " pravokotnikov na belem");
	}
}