AcWing 3203. 画图--Java
原题链接
简单
作者:
Joma
,
2021-02-17 00:59:54
,
所有人可见
,
阅读 430
二维数组存每个方块的状态,每次涂抹+1,输出大于0的方块个数
import java.io.*;
public class Main {
static int[][] a = new int[110][110];
public static void main(String[] args) throws IOException{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int ans = 0,n = Integer.parseInt(reader.readLine());
for (int i = 0; i < n; i++) {
String[] d = reader.readLine().split(" ");
for (int j = Integer.parseInt(d[0]); j < Integer.parseInt(d[2]); j++)
for (int k = Integer.parseInt(d[1]); k < Integer.parseInt(d[3]); k++)
a[j][k] ++;
}
for (int[] a1 : a)
for (int a2 : a1)
if (a2 > 0) ans ++;
System.out.println(ans);
}
}