結果

問題 No.202 1円玉投げ
ユーザー codershifthcodershifth
提出日時 2016-01-10 23:06:39
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 56 ms / 5,000 ms
コード長 2,142 bytes
コンパイル時間 1,300 ms
コンパイル使用メモリ 149,376 KB
実行使用メモリ 7,760 KB
最終ジャッジ日時 2023-08-23 23:14:34
合計ジャッジ時間 3,884 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
7,452 KB
testcase_01 AC 42 ms
7,424 KB
testcase_02 AC 3 ms
4,448 KB
testcase_03 AC 2 ms
4,388 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 4 ms
4,580 KB
testcase_06 AC 40 ms
6,668 KB
testcase_07 AC 45 ms
6,924 KB
testcase_08 AC 45 ms
6,864 KB
testcase_09 AC 23 ms
6,096 KB
testcase_10 AC 9 ms
5,040 KB
testcase_11 AC 19 ms
5,600 KB
testcase_12 AC 20 ms
5,680 KB
testcase_13 AC 11 ms
5,096 KB
testcase_14 AC 5 ms
4,556 KB
testcase_15 AC 23 ms
6,036 KB
testcase_16 AC 45 ms
7,712 KB
testcase_17 AC 47 ms
7,640 KB
testcase_18 AC 44 ms
7,496 KB
testcase_19 AC 20 ms
5,700 KB
testcase_20 AC 34 ms
6,540 KB
testcase_21 AC 21 ms
5,880 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 3 ms
4,384 KB
testcase_25 AC 2 ms
4,392 KB
testcase_26 AC 3 ms
4,548 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,384 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,544 KB
testcase_33 AC 3 ms
4,376 KB
testcase_34 AC 3 ms
4,492 KB
testcase_35 AC 52 ms
7,760 KB
testcase_36 AC 52 ms
7,440 KB
testcase_37 AC 52 ms
7,096 KB
testcase_38 AC 53 ms
7,720 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int (i)=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define RANGE(vec) (vec).begin(),(vec).end()

using namespace std;

class ThrowOneYenCoin {
public:
    static const int r = 10;
    typedef pair<int,int> Pt;
    bool hit(const Pt &a, const Pt &b) {
            int ax,ay,bx,by;
            tie(ax,ay) = a;
            tie(bx,by) = b;
            return (ax-bx)*(ax-bx)+(ay-by)*(ay-by) < 4*r*r;
    }
    void solve(void) {
            int N;
            cin>>N;

            const int B = 100;
            const int maxX = 20000;
            const int maxY = 20000;
            const int maxBX = maxX/B;
            const int maxBY = maxY/B;
            list<Pt> field[maxBY+1][maxBX+1];

            // 100*100 に含まれるコインの数は最大25程度
            // O(N*9*25)
            REP(i,N)
            {
                int x,y;
                cin>>x>>y;

                Pt p(x,y);
                int bx = x/B;
                int by = y/B;

                int dx[] = {-1,0,1};
                int dy[] = {-1,0,1};

                bool ok = true;
                REP(j,3)
                REP(k,3)
                {
                    int nx = bx+dx[j];
                    int ny = by+dy[k];

                    if (nx < 0 || ny < 0 || maxBX < nx || maxBY < ny)
                        continue;

                    auto &f = field[ny][nx];
                    for (auto c : f)
                    {
                        if ( hit(c,p) )
                            ok = false;
                    }
                }
                if (ok)
                    field[by][bx].push_back(p);
            }
            ll cnt = 0;
            REP(i,maxBX+1)
            REP(j,maxBY+1)
            {
                auto &f = field[j][i];
                cnt += f.size();
            }
            cout<<cnt<<endl;
    }
};

#if 1
int main(int argc, char *argv[])
{
        ios::sync_with_stdio(false);
        auto obj = new ThrowOneYenCoin();
        obj->solve();
        delete obj;
        return 0;
}
#endif
0