제출 코드
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
int loc[][] = new int[N][4]; //x, y, width, height
int[] paper = new int[N]; //각 색종이의 넓이
boolean[][] area = new boolean[1001][1001];
for(int n=0; n<N; n++) {
StringTokenizer st = new StringTokenizer(br.readLine());
loc[n][0] = Integer.parseInt(st.nextToken());
loc[n][1] = Integer.parseInt(st.nextToken());
loc[n][2] = Integer.parseInt(st.nextToken());
loc[n][3] = Integer.parseInt(st.nextToken());
}
for(int n=N-1; n>=0; n--) {
paper[n] = loc[n][2] * loc[n][3];
for(int i=loc[n][1]; i<loc[n][1]+loc[n][3]; i++) {
for(int j=loc[n][0]; j<loc[n][0]+loc[n][2]; j++) {
if(area[i][j] == false) {
area[i][j] = true;
}else {
paper[n]--;
}
}
}
}
for(int p : paper) {
System.out.println(p);
}
}
}