結果

問題 No.1121 Social Distancing in Cinema
ユーザー ApassApass
提出日時 2020-07-23 00:00:53
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 3,455 bytes
コンパイル時間 5,990 ms
コンパイル使用メモリ 77,244 KB
実行使用メモリ 59,836 KB
最終ジャッジ日時 2023-09-05 05:59:26
合計ジャッジ時間 20,758 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
51,268 KB
testcase_01 AC 76 ms
50,848 KB
testcase_02 AC 77 ms
49,260 KB
testcase_03 AC 79 ms
50,660 KB
testcase_04 AC 80 ms
48,804 KB
testcase_05 AC 81 ms
50,760 KB
testcase_06 AC 79 ms
50,760 KB
testcase_07 AC 81 ms
51,080 KB
testcase_08 AC 83 ms
51,252 KB
testcase_09 AC 82 ms
51,032 KB
testcase_10 AC 84 ms
51,264 KB
testcase_11 AC 85 ms
51,432 KB
testcase_12 AC 93 ms
52,748 KB
testcase_13 AC 109 ms
54,860 KB
testcase_14 AC 118 ms
54,784 KB
testcase_15 AC 167 ms
55,796 KB
testcase_16 AC 212 ms
57,084 KB
testcase_17 AC 296 ms
59,608 KB
testcase_18 AC 363 ms
59,504 KB
testcase_19 AC 404 ms
59,224 KB
testcase_20 AC 168 ms
55,376 KB
testcase_21 AC 168 ms
57,848 KB
testcase_22 AC 164 ms
56,532 KB
testcase_23 AC 119 ms
55,168 KB
testcase_24 AC 103 ms
53,708 KB
testcase_25 AC 278 ms
57,440 KB
testcase_26 AC 296 ms
58,548 KB
testcase_27 AC 154 ms
56,020 KB
testcase_28 AC 389 ms
59,596 KB
testcase_29 AC 287 ms
58,544 KB
testcase_30 AC 277 ms
59,240 KB
testcase_31 AC 399 ms
59,516 KB
testcase_32 AC 348 ms
58,896 KB
testcase_33 AC 289 ms
59,280 KB
testcase_34 AC 281 ms
59,224 KB
testcase_35 AC 360 ms
59,440 KB
testcase_36 AC 396 ms
59,732 KB
testcase_37 AC 247 ms
57,056 KB
testcase_38 AC 286 ms
59,184 KB
testcase_39 AC 383 ms
59,836 KB
testcase_40 AC 228 ms
56,296 KB
testcase_41 AC 184 ms
56,084 KB
testcase_42 AC 391 ms
59,528 KB
testcase_43 AC 408 ms
59,416 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 77 ms
50,624 KB
testcase_48 AC 77 ms
50,720 KB
権限があれば一括ダウンロードができます

ソースコード

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