結果
| 問題 | No.755 Zero-Sum Rectangle | 
| コンテスト | |
| ユーザー |  tenten | 
| 提出日時 | 2020-09-01 16:45:11 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                TLE
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 1,484 bytes | 
| コンパイル時間 | 3,390 ms | 
| コンパイル使用メモリ | 77,244 KB | 
| 実行使用メモリ | 58,872 KB | 
| 最終ジャッジ日時 | 2024-11-19 06:57:22 | 
| 合計ジャッジ時間 | 16,819 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 10 TLE * 2 | 
ソースコード
import java.util.*;
public class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int m = sc.nextInt();
        long[][] field = new long[m + 1][m + 1];
        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= m; j++) {
                field[i][j] = field[i][j - 1] + field[i - 1][j] - field[i - 1][j - 1] + sc.nextInt();
            }
        }
        int[] xArr = new int[n];
        int[] yArr = new int[n];
        for (int i = 0; i < n; i++) {
            xArr[i] = sc.nextInt();
            yArr[i] = sc.nextInt();
        }
        int[] counts = new int[n];
        for (int a = 1; a <= m; a++) {
            for (int b = 1; b <= m; b++) {
                for (int c = a; c <= m; c++) {
                    for (int d = b; d <= m; d++) {
                        if (field[c][d] - field[a - 1][d] - field[c][b - 1] + field[a- 1][b - 1] != 0) {
                            continue;
                        }
                        for (int i = 0; i < n; i++) {
                            if (xArr[i] >= a && xArr[i] <= c && yArr[i] >= b && yArr[i] <= d) {
                                counts[i]++;
                            }
                        }
                    }
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int x : counts) {
            sb.append(x).append("\n");
        }
    	System.out.print(sb);
    }
}
            
            
            
        