19moyudaren @ 2022-03-09 16:34:28
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int n=in.nextInt(),m=in.nextInt();
int[][] tmp=new int[n+2][n+2];
for (int i = 1; i <= m; i++) {
int beginX=in.nextInt(),beginY=in.nextInt(),endX=in.nextInt(),endY=in.nextInt();
tmp[beginX][beginY]++;
tmp[endX+1][beginY]--;
tmp[beginX][endY+1]--;
tmp[endX+1][endY+1]++;
}
in.close();
for (int i = 1; i <= n; i++) {
for (int j=1; j <=n; j++) {
tmp[i][j]+=tmp[i-1][j]+tmp[i][j-1]-tmp[i-1][j-1];
if(j==n) {
System.out.println(tmp[i][j]);
}else {
System.out.print(tmp[i][j]+" ");
}
}
}
}
by ssytxy2024 @ 2022-03-09 16:35:43
@19moyudaren 是JAVA太慢了,不存在卡语言这种说法
by LOREaaa @ 2022-03-16 10:36:03
我也很纳闷
by ljqiscaiji @ 2022-03-31 21:55:34
确实啊 二维差分python也没过 都是1.07秒左右,不知道怎么优化了,很烦