結果

問題 No.202 1円玉投げ
ユーザー hogeover30
提出日時 2015-05-12 02:15:07
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 309 ms / 5,000 ms
コード長 898 bytes
コンパイル時間 627 ms
コンパイル使用メモリ 73,252 KB
実行使用メモリ 9,856 KB
最終ジャッジ日時 2024-12-22 09:03:09
合計ジャッジ時間 4,581 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <set>
#include <map>
using namespace std;
bool is_overlap(int x0, int y0, int x1, int y1)
{
#define sq(x) ((x)*(x))
#define dist(a, b, c, d) (sq(a-c)+sq(b-d))
    return dist(x0, y0, x1, y1)<400;
}

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

    int n; cin>>n;
    map<int, set<int>> a;
    for(int $=0;$<n;++$) {
        int x, y; cin>>x>>y;
        bool overlap=false;
        for(auto i=a.lower_bound(x-20);i!=a.end();++i) {
            if (i->first-20>=x+20) break;
            auto& b=i->second;
            for(auto j=b.lower_bound(y-20);j!=b.end();++j) {
                if (*j-20>=y+20) break;
                if (overlap=is_overlap(x, y, i->first, *j)) break;
            }
            if (overlap) break;
        }
        if (!overlap) a[x].insert(y);
    }
    int res=0;
    for(auto&v: a) res+=v.second.size();
    cout<<res<<endl;
}
0