結果
| 問題 | No.755 Zero-Sum Rectangle |
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2021-11-02 17:26:01 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 1,946 ms / 2,000 ms |
| コード長 | 2,142 bytes |
| 記録 | |
| コンパイル時間 | 2,342 ms |
| コンパイル使用メモリ | 77,636 KB |
| 実行使用メモリ | 57,088 KB |
| 最終ジャッジ日時 | 2024-10-11 22:10:32 |
| 合計ジャッジ時間 | 13,213 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 11 TLE * 1 |
ソースコード
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner();
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 - 1][j] + field[i][j - 1] - field[i - 1][j - 1] + sc.nextInt();
}
}
int[] xs = new int[n];
int[] ys = new int[n];
for (int i = 0; i < n; i++) {
xs[i] = sc.nextInt();
ys[i] = sc.nextInt();
}
int[] ans = new int[n];
for (int i = 0; i < m; i++) {
for (int j = 0; j < m; j++) {
for (int k = i + 1; k <= m; k++) {
for (int l = j + 1; l <= m; l++) {
if (field[k][l] - field[i][l] - field[k][j] + field[i][j] == 0) {
for (int a = 0; a < n; a++) {
if (xs[a] > i && xs[a] <= k && ys[a] > j && ys[a] <= l) {
ans[a]++;
}
}
}
}
}
}
}
StringBuilder sb = new StringBuilder();
for (int x : ans) {
sb.append(x).append("\n");
}
System.out.print(sb);
}
}
class Scanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
public Scanner() throws Exception {
}
public int nextInt() throws Exception {
return Integer.parseInt(next());
}
public long nextLong() throws Exception {
return Long.parseLong(next());
}
public String nextLine() throws Exception {
return br.readLine();
}
public String next() throws Exception {
if (!st.hasMoreTokens()) {
st = new StringTokenizer(br.readLine());
}
return st.nextToken();
}
}
tenten