|
| 1 | +``` |
| 2 | +import java.io.*; |
| 3 | +import java.util.*; |
| 4 | +
|
| 5 | +public class Main { |
| 6 | + private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); |
| 7 | + private static final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); |
| 8 | + private static final int[] dx = {1, 1, -1, -1}; |
| 9 | + private static final int[] dy = {1, -1, 1, -1}; |
| 10 | + private static List<int[]> nets, fishes; |
| 11 | + private static boolean[][] map; |
| 12 | + private static int N, I, M, answer; |
| 13 | +
|
| 14 | + public static void main(String[] args) throws IOException { |
| 15 | + init(); |
| 16 | +
|
| 17 | + for (int[] pos : fishes){ |
| 18 | + for (int[] net : nets) { |
| 19 | + for (int i = pos[0]-net[0]; i <= pos[0]+net[0]; i++) { |
| 20 | + int count = 0; |
| 21 | + for (int[] fish : fishes) { |
| 22 | + if (i <= fish[0] && fish[0] <= i+net[0] && pos[1] <= fish[1] && fish[1] <= pos[1]+net[1]) count++; |
| 23 | + } |
| 24 | + answer = Math.max(answer, count); |
| 25 | + } |
| 26 | +
|
| 27 | + for (int i = pos[1]-net[1]; i <= pos[1]+net[1]; i++) { |
| 28 | + int count = 0; |
| 29 | + for (int[] fish : fishes) { |
| 30 | + if (i <= fish[1] && fish[1] <= i+net[1] && pos[0] <= fish[0] && fish[0] <= pos[0]+net[0]) count++; |
| 31 | + } |
| 32 | + answer = Math.max(answer, count); |
| 33 | + } |
| 34 | + } |
| 35 | + } |
| 36 | +
|
| 37 | + bw.write(answer + "\n"); |
| 38 | + bw.flush(); |
| 39 | + bw.close(); |
| 40 | + br.close(); |
| 41 | + } |
| 42 | +
|
| 43 | + private static void init() throws IOException { |
| 44 | + StringTokenizer st = new StringTokenizer(br.readLine()); |
| 45 | + N = Integer.parseInt(st.nextToken()); |
| 46 | + I = Integer.parseInt(st.nextToken()); |
| 47 | + M = Integer.parseInt(st.nextToken()); |
| 48 | +
|
| 49 | + map = new boolean[N+1][N+1]; |
| 50 | + fishes = new ArrayList<>(); |
| 51 | +
|
| 52 | + for (int i = 0; i < M; i++) { |
| 53 | + st = new StringTokenizer(br.readLine()); |
| 54 | + int x = Integer.parseInt(st.nextToken()); |
| 55 | + int y = Integer.parseInt(st.nextToken()); |
| 56 | +
|
| 57 | + map[x][y] = true; |
| 58 | + fishes.add(new int[]{x, y}); |
| 59 | + } |
| 60 | +
|
| 61 | + nets = makeNet(); |
| 62 | + } |
| 63 | +
|
| 64 | + private static List<int[]> makeNet() { |
| 65 | + List<int[]> nets = new ArrayList<>(); |
| 66 | +
|
| 67 | + int r = 1; |
| 68 | + int c = I/2-1; |
| 69 | +
|
| 70 | + while (c > 0) { |
| 71 | + nets.add(new int[]{r, c}); |
| 72 | + r++; |
| 73 | + c--; |
| 74 | + } |
| 75 | +
|
| 76 | + return nets; |
| 77 | + } |
| 78 | +
|
| 79 | + private static boolean OOB(int x, int y) { |
| 80 | + return x < 1 || x > N || y < 1 || y > N; |
| 81 | + } |
| 82 | +} |
| 83 | +``` |
0 commit comments