結果

問題 No.1121 Social Distancing in Cinema
ユーザー ApassApass
提出日時 2020-07-23 00:00:53
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 3,455 bytes
コンパイル時間 3,563 ms
コンパイル使用メモリ 80,432 KB
実行使用メモリ 49,216 KB
最終ジャッジ日時 2024-06-23 02:25:07
合計ジャッジ時間 16,169 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 44 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

public class SocialDistancingInCinema {
    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
    };
    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();
        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<>();
        for (int i = 9; i <= 508; i++) {
            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;
                        }
                    }
                }
            }
        }

        return selected;
    }
}
0