結果
| 問題 | 
                            No.202 1円玉投げ
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tenten
                         | 
                    
| 提出日時 | 2022-08-19 18:25:30 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 817 ms / 5,000 ms | 
| コード長 | 2,296 bytes | 
| コンパイル時間 | 2,424 ms | 
| コンパイル使用メモリ | 79,032 KB | 
| 実行使用メモリ | 74,324 KB | 
| 最終ジャッジ日時 | 2024-12-22 12:13:36 | 
| 合計ジャッジ時間 | 18,644 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 38 | 
ソースコード
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        ArrayList<ArrayList<ArrayList<Circle>>> grid = new ArrayList<>();
        for (int i = 0; i <= 100; i++) {
            grid.add(new ArrayList<>());
            for (int j = 0; j <= 100; j++) {
                grid.get(i).add(new ArrayList<>());
            }
        }
        int count = 0;
        while (n-- > 0) {
            Circle x = new Circle(sc.nextInt(), sc.nextInt());
            boolean enable = true;
            for (int i = Math.max(x.r - 1, 0); i <= Math.min(x.r + 1, 100) && enable; i++) {
                for (int j = Math.max(x.c - 1, 0); j <= Math.min(x.c + 1, 100) && enable; j++) {
                    for (Circle y : grid.get(i).get(j)) {
                        if (x.same(y)) {
                            enable = false;
                            break;
                        }
                    }
                }
            }
            if (enable) {
                count++;
                grid.get(x.r).get(x.c).add(x);
            }
        }
        System.out.println(count);
    }
    
    static class Circle {
        int x;
        int y;
        int r;
        int c;
        
        public Circle(int x, int y) {
            this.x = x;
            this.y = y;
            r = x / 200;
            c = y / 200;
        }
        
        public boolean same(Circle z) {
            return (x - z.x) * (x - z.x) + (y - z.y) * (y - z.y) < 400;
        }
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
            
            
            
        
            
tenten