結果

問題 No.1121 Social Distancing in Cinema
ユーザー ApassApass
提出日時 2020-07-22 23:56:27
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 3,470 bytes
コンパイル時間 5,191 ms
コンパイル使用メモリ 81,784 KB
実行使用メモリ 60,928 KB
最終ジャッジ日時 2023-09-05 05:48:55
合計ジャッジ時間 20,545 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
50,656 KB
testcase_01 AC 75 ms
50,544 KB
testcase_02 AC 75 ms
50,552 KB
testcase_03 AC 74 ms
50,940 KB
testcase_04 AC 77 ms
50,944 KB
testcase_05 AC 77 ms
50,876 KB
testcase_06 AC 78 ms
50,888 KB
testcase_07 AC 79 ms
50,644 KB
testcase_08 AC 78 ms
51,196 KB
testcase_09 AC 78 ms
50,844 KB
testcase_10 AC 84 ms
52,988 KB
testcase_11 AC 85 ms
52,036 KB
testcase_12 AC 88 ms
51,256 KB
testcase_13 AC 104 ms
54,932 KB
testcase_14 AC 113 ms
54,596 KB
testcase_15 AC 161 ms
55,748 KB
testcase_16 AC 211 ms
58,452 KB
testcase_17 AC 295 ms
59,780 KB
testcase_18 AC 391 ms
60,096 KB
testcase_19 AC 404 ms
59,548 KB
testcase_20 AC 165 ms
55,400 KB
testcase_21 AC 163 ms
55,960 KB
testcase_22 AC 164 ms
57,084 KB
testcase_23 AC 114 ms
54,400 KB
testcase_24 AC 100 ms
53,576 KB
testcase_25 AC 273 ms
58,580 KB
testcase_26 AC 294 ms
59,060 KB
testcase_27 AC 151 ms
56,284 KB
testcase_28 AC 387 ms
58,948 KB
testcase_29 AC 290 ms
57,876 KB
testcase_30 AC 242 ms
56,660 KB
testcase_31 AC 399 ms
59,192 KB
testcase_32 AC 365 ms
58,996 KB
testcase_33 AC 284 ms
59,208 KB
testcase_34 AC 274 ms
59,316 KB
testcase_35 AC 361 ms
59,236 KB
testcase_36 AC 384 ms
59,228 KB
testcase_37 AC 247 ms
57,176 KB
testcase_38 AC 276 ms
58,552 KB
testcase_39 AC 382 ms
59,696 KB
testcase_40 AC 227 ms
56,296 KB
testcase_41 AC 177 ms
56,012 KB
testcase_42 AC 389 ms
59,112 KB
testcase_43 AC 390 ms
59,696 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 75 ms
50,764 KB
testcase_48 AC 75 ms
49,128 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.println(i + " ");
        }
        pw.close();
    }

    private static ArrayList<Integer> solve() throws IOException {
        int N = readInt();
        int[][] index = new int[518][518];
        boolean[][] present = new boolean[518][518]; // 0 safe, 1 to check, 2 forbidden
        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