結果

問題 No.202 1円玉投げ
ユーザー cormorancormoran
提出日時 2016-10-04 18:56:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 347 ms / 5,000 ms
コード長 1,355 bytes
コンパイル時間 1,585 ms
コンパイル使用メモリ 164,900 KB
実行使用メモリ 14,932 KB
最終ジャッジ日時 2023-08-23 23:29:16
合計ジャッジ時間 7,103 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 184 ms
14,920 KB
testcase_01 AC 342 ms
14,836 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 14 ms
4,376 KB
testcase_06 AC 269 ms
11,944 KB
testcase_07 AC 311 ms
12,724 KB
testcase_08 AC 321 ms
12,796 KB
testcase_09 AC 159 ms
8,912 KB
testcase_10 AC 60 ms
6,028 KB
testcase_11 AC 126 ms
8,036 KB
testcase_12 AC 130 ms
8,060 KB
testcase_13 AC 67 ms
6,396 KB
testcase_14 AC 17 ms
4,412 KB
testcase_15 AC 152 ms
8,876 KB
testcase_16 AC 206 ms
14,828 KB
testcase_17 AC 72 ms
14,852 KB
testcase_18 AC 72 ms
14,896 KB
testcase_19 AC 142 ms
8,376 KB
testcase_20 AC 241 ms
11,168 KB
testcase_21 AC 141 ms
8,388 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 3 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 3 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 3 ms
4,380 KB
testcase_33 AC 3 ms
4,376 KB
testcase_34 AC 4 ms
4,380 KB
testcase_35 AC 116 ms
14,864 KB
testcase_36 AC 111 ms
14,932 KB
testcase_37 AC 347 ms
13,540 KB
testcase_38 AC 117 ms
14,892 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)

class Solver {
  public:
    bool cross(pii a, pii b) {
        return pow(a.first - b.first, 2) + pow(a.second - b.second, 2) < 20 * 20;
    }
    
    bool solve() {
        int N; cin >> N;
        vector<int> X(N), Y(N);
        rep(i, N) cin >> X[i] >> Y[i];

        map<int, map<int, vector<pii>>> G;
        int ans = 0;
        rep(i, N) {
            int x = X[i], y = Y[i];
            int gx = x / 10, gy = y / 10;
            repeat(dgy, -2, 2 + 1) {
                if(G.count(gy + dgy)) {
                    repeat(dgx, -2, 2 + 1) {
                        if(G[gy + dgy].count(gx + dgx)) {
                            for(pii p : G[gy +  dgy][gx + dgx]) {
                                if(cross(p, make_pair(y, x))) goto FAIL;
                            }
                        }                        
                    }
                }
            }
            G[gy][gx].push_back(make_pair(y, x));
            ans++;
      FAIL:;            
        }
        cout << ans << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}
0