結果
| 問題 |
No.1121 Social Distancing in Cinema
|
| コンテスト | |
| ユーザー |
Apass
|
| 提出日時 | 2020-07-29 10:14:35 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 4,177 bytes |
| コンパイル時間 | 3,191 ms |
| コンパイル使用メモリ | 85,032 KB |
| 実行使用メモリ | 60,712 KB |
| 最終ジャッジ日時 | 2024-06-28 21:27:48 |
| 合計ジャッジ時間 | 21,140 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | AC * 1 WA * 46 |
ソースコード
import java.io.*;
import java.util.*;
public class SocialDistancingInCinema {
//@formatter:off
static final int[][] forbiddenNeighbors = {
{-4,-3,-2,-1, 0, 1, 2, 3, 4,}, // -9
{-5,-4,-3,-2,-1, 0, 1, 2, 3, 4, 5,}, // -8
{-7,-6,-5,-4,-3,-2,-1, 0, 1, 2, 3, 4, 5, 6, 7,}, // -7
{-7,-6,-5,-4,-3,-2,-1, 0, 1, 2, 3, 4, 5, 6, 7,}, // -6
{-8,-7,-6,-5,-4,-3,-2,-1, 0, 1, 2, 3, 4, 5, 6, 7, 8,}, // -5
{-9,-8,-7,-6,-5,-4,-3,-2,-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,}, // -4
{-9,-8,-7,-6,-5,-4,-3,-2,-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,}, // -3
{-9,-8,-7,-6,-5,-4,-3,-2,-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,}, // -2
{-9,-8,-7,-6,-5,-4,-3,-2,-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,}, // -1
{-9,-8,-7,-6,-5,-4,-3,-2,-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,}, // 0
{-9,-8,-7,-6,-5,-4,-3,-2,-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,}, // 1
{-9,-8,-7,-6,-5,-4,-3,-2,-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,}, // 2
{-9,-8,-7,-6,-5,-4,-3,-2,-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,}, // 3
{-9,-8,-7,-6,-5,-4,-3,-2,-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,}, // 4
{-8,-7,-6,-5,-4,-3,-2,-1, 0, 1, 2, 3, 4, 5, 6, 7, 8,}, // 5
{-7,-6,-5,-4,-3,-2,-1, 0, 1, 2, 3, 4, 5, 6, 7,}, // 6
{-7,-6,-5,-4,-3,-2,-1, 0, 1, 2, 3, 4, 5, 6, 7,}, // 7
{-5,-4,-3,-2,-1, 0, 1, 2, 3, 4, 5,}, // 8
{-4,-3,-2,-1, 0, 1, 2, 3, 4,}, // 9
};
//@formatter:on
static final int[] length = {9, 11, 15, 15, 17, 19, 19, 19, 19, 19, 19, 19, 19, 19, 17, 15, 15, 11, 9};
private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
private static StringTokenizer st;
private static int readInt() throws IOException {
while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
return Integer.parseInt(st.nextToken());
}
public static void main(String[] args) throws IOException {
ArrayList<Integer> answer = solve();
pw.println(answer.size());
for (int i : answer) {
pw.print(i + " ");
}
pw.println();
pw.close();
}
private static ArrayList<Integer> solve() throws IOException {
int N = readInt();
System.out.println(N);
int[][] index = new int[518][518];
boolean[][] present = new boolean[518][518];
for (int i = 1; i <= N; i++) {
int x = readInt() + 8;
int y = readInt() + 8;
index[x][y] = i;
present[x][y] = true;
}
ArrayList<Integer> selected = new ArrayList<>();
int direction = 1;
for (int i = 9; i <= 508; i++) {
int keepDirection = 1;
if (direction == 1) {
for (int j = 9; j <= 508; j++) {
if (present[i][j]) {
selected.add(index[i][j]);
for (int k = 0, r = -9; k < 19; k++, r++) {
for (int l = length[k] - 1; l >= 0; l--) {
present[i + r][j + forbiddenNeighbors[k][l]] = false;
}
}
keepDirection = -1;
}
}
} else {
for (int j = 508; j >= 9; j--) {
if (present[i][j]) {
selected.add(index[i][j]);
for (int k = 0, r = -9; k < 19; k++, r++) {
for (int l = length[k] - 1; l >= 0; l--) {
present[i + r][j + forbiddenNeighbors[k][l]] = false;
}
}
keepDirection = -1;
}
}
}
direction *= keepDirection;
}
return selected;
}
}
Apass