关于模拟题(部分代码)
// fluorite for (int i = 0; i < k; i++) { for (int j = 0; j < 5; j++) { for (int j2 = 0; j2 < 5; j2++) { if (f(c[i][0] + (j - 2), c[i][1] + (j2 - 2), n)) { a[c[i][0] + (j - 2)][c[i][1] + (j2 - 2)] = 1; } } } } // torch for (int i = 0; i < m; i++) { for (int j = 0; j < 5; j++) { for (int j2 = 0; j2 < Math.abs(Math.abs(j - 2) - 2) * 2 + 1; j2++) { if (f(b[i][1] + j - 2, b[i][0] + j2 - Math.abs(Math.abs(j - 2) - 2), n)) { a[b[i][0] + j2 - Math.abs(Math.abs(j - 2) - 2)][b[i][1] + j - 2] = 1; } } } }
菱形矩阵-固定大小-半暴力循环 代码
int n = in.nextInt(), m = in.nextInt(), x = in.nextInt(), y = in.nextInt(); int a[][][] = new int[n + 1][m + 1][2]; for (int i = 1; i <= x; i++) { int x1 = in.nextInt(), y1 = in.nextInt(), x2 = in.nextInt(), y2 = in.nextInt(); for (int j = 0; j <= x2 - x1; j++) { for (int j2 = 0; j2 <= y2 - y1; j2++) { a[x1 + j][y1 + j2][0]++; a[x1 + j][y1 + j2][1] = i; } } }
矩阵-区域覆盖
每个点都有两个属性(a[x][y][2])
0是覆盖次数,1是最后一次的覆盖次数