結果
問題 | No.1121 Social Distancing in Cinema |
ユーザー | Apass |
提出日時 | 2020-07-22 23:56:27 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,470 bytes |
コンパイル時間 | 4,598 ms |
コンパイル使用メモリ | 80,848 KB |
実行使用メモリ | 49,464 KB |
最終ジャッジ日時 | 2024-06-23 02:15:50 |
合計ジャッジ時間 | 16,882 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 75 ms
39,104 KB |
testcase_01 | AC | 74 ms
39,068 KB |
testcase_02 | AC | 74 ms
39,460 KB |
testcase_03 | AC | 71 ms
39,224 KB |
testcase_04 | AC | 72 ms
39,156 KB |
testcase_05 | AC | 74 ms
39,348 KB |
testcase_06 | AC | 74 ms
39,528 KB |
testcase_07 | AC | 72 ms
39,520 KB |
testcase_08 | AC | 73 ms
39,528 KB |
testcase_09 | AC | 76 ms
39,060 KB |
testcase_10 | AC | 80 ms
39,848 KB |
testcase_11 | AC | 79 ms
39,720 KB |
testcase_12 | AC | 85 ms
40,036 KB |
testcase_13 | AC | 99 ms
40,900 KB |
testcase_14 | AC | 111 ms
41,260 KB |
testcase_15 | AC | 145 ms
42,856 KB |
testcase_16 | AC | 216 ms
48,244 KB |
testcase_17 | AC | 262 ms
47,968 KB |
testcase_18 | AC | 348 ms
48,748 KB |
testcase_19 | AC | 352 ms
49,176 KB |
testcase_20 | AC | 156 ms
42,836 KB |
testcase_21 | AC | 137 ms
42,148 KB |
testcase_22 | AC | 150 ms
41,828 KB |
testcase_23 | AC | 113 ms
41,284 KB |
testcase_24 | AC | 101 ms
40,616 KB |
testcase_25 | AC | 260 ms
47,140 KB |
testcase_26 | AC | 267 ms
48,440 KB |
testcase_27 | AC | 146 ms
41,488 KB |
testcase_28 | AC | 342 ms
48,656 KB |
testcase_29 | AC | 269 ms
47,672 KB |
testcase_30 | AC | 227 ms
46,048 KB |
testcase_31 | AC | 358 ms
48,572 KB |
testcase_32 | AC | 327 ms
48,396 KB |
testcase_33 | AC | 241 ms
47,792 KB |
testcase_34 | AC | 262 ms
47,200 KB |
testcase_35 | AC | 330 ms
48,976 KB |
testcase_36 | AC | 369 ms
49,076 KB |
testcase_37 | AC | 218 ms
46,088 KB |
testcase_38 | AC | 267 ms
47,720 KB |
testcase_39 | AC | 348 ms
48,476 KB |
testcase_40 | AC | 217 ms
45,656 KB |
testcase_41 | AC | 171 ms
45,096 KB |
testcase_42 | AC | 364 ms
48,848 KB |
testcase_43 | AC | 358 ms
48,704 KB |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | AC | 69 ms
39,212 KB |
testcase_48 | AC | 74 ms
39,268 KB |
ソースコード
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; } }