提出 #71327830
ソースコード 拡げる
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
class Main {
public static void main(String[] args) {
PrintWriter out = new PrintWriter(System.out);
FastScanner sc = new FastScanner();
int N = sc.nextInt();
int[][] grid = new int[2002][2002];
int[] U = new int[N];
int[] L = new int[N];
int[] D = new int[N];
int[] R = new int[N];
for (int i = 0; i < N; i++) {
U[i] = sc.nextInt();
D[i] = sc.nextInt();
L[i] = sc.nextInt();
R[i] = sc.nextInt();
grid[U[i]][L[i]] += 1;
grid[U[i]][R[i]+1] -= 1;
grid[D[i]+1][L[i]] -= 1;
grid[D[i]+1][R[i]+1] += 1;
}
for (int i = 1; i < 2001; i++) {
for (int j = 1; j < 2001; j++) {
grid[i][j] += grid[i][j-1];
}
}
for (int i = 1; i < 2001; i++) {
for (int j = 1; j < 2001; j++) {
grid[j][i] += grid[j-1][i];
}
}
// for (int i = 0; i < 10; i++) {
// for (int j = 0; j < 2002; j++) {
// System.out.print(grid[i][j]);
// }
// System.out.println();
// }
int all = 0;
for (int i = 1; i < 2001; i++) {
for (int j = 1; j < 2001; j++) {
if (grid[i][j] == 0) all++;
}
}
for (int i = 0; i < 2002; i++) {
for (int j = 0; j < 2002; j++) {
if (grid[i][j] != 1) grid[i][j] = 0;
// if (grid[i][j] == 2){
// grid[i][j] = 1;
// // grid[i][j+1] -= 1;
// // grid[i+1][j] -= 1;
// // grid[i+1][j+1] += 1;
// }
}
}
for (int i = 1; i < 2001; i++) {
for (int j = 1; j < 2001; j++) {
grid[i][j] += grid[i][j-1];
}
}
for (int i = 1; i < 2001; i++) {
for (int j = 1; j < 2001; j++) {
grid[j][i] += grid[j-1][i];
}
}
// for (int i = 0; i < 10; i++) {
// for (int j = 0; j < 2002; j++) {
// System.out.print(grid[i][j]);
// }
// System.out.println();
// }
// System.out.println();
for (int i = 0; i < N; i++) {
System.out.println(all + grid[D[i]][R[i]] + grid[U[i]-1][L[i]-1] - grid[U[i]-1][R[i]] - grid[D[i]][L[i]-1]);
// System.out.println(grid[D[i]][R[i]] + grid[U[i]-1][L[i]-1] - grid[U[i]-1][R[i]] - grid[D[i]][L[i]-1]);
}
out.flush();
}
private static class FastScanner {
private final InputStream in = System.in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
} else {
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
return buflen > 0;
}
}
private int readByte() {
if (hasNextByte()) return buffer[ptr++];
else return -1;
}
private static boolean isPrintableChar(int c) {
return 33 <= c && c <= 126;
}
public boolean hasNext() {
while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
return !hasNextByte();
}
public String next() {
if (hasNext()) throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while (isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
if (hasNext()) throw new NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while (true) {
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
} else if (b == -1 || !isPrintableChar(b)) {
return minus ? -n : n;
} else {
throw new NumberFormatException();
}
b = readByte();
}
}
public int nextInt() {
long nl = nextLong();
if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
return (int) nl;
}
public double nextDouble() {
return Double.parseDouble(next());
}
}
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | D - Clouds |
| ユーザ | AAH_tomato |
| 言語 | Java24 (OpenJDK 24.0.2) |
| 得点 | 425 |
| コード長 | 5350 Byte |
| 結果 | AC |
| 実行時間 | 554 ms |
| メモリ | 84496 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 425 / 425 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | sample_01.txt |
| All | sample_01.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt, test_45.txt, test_46.txt, test_47.txt, test_48.txt, test_49.txt, test_50.txt, test_51.txt, test_52.txt, test_53.txt, test_54.txt, test_55.txt, test_56.txt, test_57.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| sample_01.txt | AC | 140 ms | 58872 KiB |
| test_01.txt | AC | 186 ms | 59720 KiB |
| test_02.txt | AC | 514 ms | 78692 KiB |
| test_03.txt | AC | 418 ms | 83656 KiB |
| test_04.txt | AC | 470 ms | 79148 KiB |
| test_05.txt | AC | 458 ms | 84004 KiB |
| test_06.txt | AC | 460 ms | 83928 KiB |
| test_07.txt | AC | 466 ms | 78844 KiB |
| test_08.txt | AC | 209 ms | 73344 KiB |
| test_09.txt | AC | 363 ms | 79012 KiB |
| test_10.txt | AC | 422 ms | 79404 KiB |
| test_11.txt | AC | 363 ms | 79032 KiB |
| test_12.txt | AC | 394 ms | 79084 KiB |
| test_13.txt | AC | 176 ms | 57948 KiB |
| test_14.txt | AC | 245 ms | 74356 KiB |
| test_15.txt | AC | 156 ms | 74948 KiB |
| test_16.txt | AC | 180 ms | 73540 KiB |
| test_17.txt | AC | 281 ms | 79044 KiB |
| test_18.txt | AC | 371 ms | 78980 KiB |
| test_19.txt | AC | 172 ms | 58720 KiB |
| test_20.txt | AC | 144 ms | 74672 KiB |
| test_21.txt | AC | 192 ms | 75428 KiB |
| test_22.txt | AC | 162 ms | 74896 KiB |
| test_23.txt | AC | 141 ms | 59136 KiB |
| test_24.txt | AC | 267 ms | 78064 KiB |
| test_25.txt | AC | 228 ms | 74128 KiB |
| test_26.txt | AC | 318 ms | 78340 KiB |
| test_27.txt | AC | 235 ms | 74312 KiB |
| test_28.txt | AC | 154 ms | 74792 KiB |
| test_29.txt | AC | 197 ms | 75380 KiB |
| test_30.txt | AC | 141 ms | 58920 KiB |
| test_31.txt | AC | 451 ms | 79240 KiB |
| test_32.txt | AC | 166 ms | 74824 KiB |
| test_33.txt | AC | 514 ms | 79268 KiB |
| test_34.txt | AC | 535 ms | 79184 KiB |
| test_35.txt | AC | 528 ms | 79272 KiB |
| test_36.txt | AC | 494 ms | 84360 KiB |
| test_37.txt | AC | 493 ms | 78984 KiB |
| test_38.txt | AC | 548 ms | 79124 KiB |
| test_39.txt | AC | 506 ms | 83788 KiB |
| test_40.txt | AC | 521 ms | 79208 KiB |
| test_41.txt | AC | 537 ms | 79016 KiB |
| test_42.txt | AC | 532 ms | 79156 KiB |
| test_43.txt | AC | 527 ms | 79116 KiB |
| test_44.txt | AC | 551 ms | 78840 KiB |
| test_45.txt | AC | 501 ms | 78692 KiB |
| test_46.txt | AC | 523 ms | 78832 KiB |
| test_47.txt | AC | 554 ms | 79084 KiB |
| test_48.txt | AC | 538 ms | 80432 KiB |
| test_49.txt | AC | 554 ms | 79340 KiB |
| test_50.txt | AC | 530 ms | 79048 KiB |
| test_51.txt | AC | 509 ms | 78536 KiB |
| test_52.txt | AC | 540 ms | 84496 KiB |
| test_53.txt | AC | 550 ms | 84396 KiB |
| test_54.txt | AC | 548 ms | 79344 KiB |
| test_55.txt | AC | 508 ms | 84300 KiB |
| test_56.txt | AC | 507 ms | 78756 KiB |
| test_57.txt | AC | 525 ms | 79172 KiB |