結果

問題 No.202 1円玉投げ
ユーザー agatan
提出日時 2015-05-04 18:29:39
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,413 bytes
コンパイル時間 888 ms
コンパイル使用メモリ 74,104 KB
実行使用メモリ 100,216 KB
最終ジャッジ日時 2024-12-22 08:22:12
合計ジャッジ時間 4,222 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 30 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <cmath>
#include <array>

#define REP(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef pair<int, int> P;

const int MAX_N = 100000;
array<array<vector<P>, 2000>, 20000 / 10> fields;

bool is_on(pair<int,int> &a, pair<int, int> &b)
{
    double dist = (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second);
    dist = sqrt(dist);
    return dist < 20;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    int x, y;
    cin >> x >> y;
    N--;
    vector<pair<int, int> > coins;
    coins.emplace_back(x, y);

    int ans = 1;

    REP(k, N) {
        cin >> x >> y;
        P current(x, y);
        int fx = x / 20, fy = y / 20;
        bool flg = true;
        for (int i = -1; i <= 1 && flg; ++i) {
            for (int j = -1; j <= 1 && flg; ++j) {
                if (fx + i < 0 || fx + i >= 2000 || fy + j < 0 || fy + j >= 2000) continue;
                for (auto p: fields[fx + i][fy + j]) {
                    if (is_on(p, current)) {
                        flg = false;
                        break;
                    }
                }
            }
        }
        if (flg) {
            fields[fx][fy].push_back(current);
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}
0