結果

問題 No.755 Zero-Sum Rectangle
ユーザー htensaihtensai
提出日時 2020-01-29 08:47:39
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,323 bytes
コンパイル時間 3,740 ms
コンパイル使用メモリ 73,396 KB
実行使用メモリ 61,908 KB
最終ジャッジ日時 2023-10-14 00:13:50
合計ジャッジ時間 6,951 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,832 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 308 ms
60,688 KB
testcase_10 AC 320 ms
60,240 KB
testcase_11 AC 134 ms
54,200 KB
evil_1 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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[][] sums = new long[m + 1][m + 1];
        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= m; j++) {
                sums[i][j] = sc.nextInt() + sums[i - 1][j] + sums[i][j - 1] - sums[i - 1][j - 1];
            }
        }
        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();
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            int ans = 0;
            for (int x1 = 1; x1 <= xArr[i]; x1++) {
                for (int x2 = xArr[i]; x2 <= n; x2++) {
                    for (int y1 = 1; y1 <= yArr[i]; y1++) {
                        for (int y2 = yArr[i]; y2 <= n; y2++) {
                            if (sums[x2][y2] - sums[x1 - 1][y2] - sums[x2][y1 - 1] + sums[x1 - 1][y1 - 1] == 0) {
                                ans++;
                            }
                        }
                    }
                }
            }
            sb.append(ans).append("\n");
        }
        System.out.print(sb);
    }
}
0