結果
問題 | No.202 1円玉投げ |
ユーザー |
![]() |
提出日時 | 2016-01-10 23:06:39 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 54 ms / 5,000 ms |
コード長 | 2,142 bytes |
コンパイル時間 | 1,621 ms |
コンパイル使用メモリ | 163,052 KB |
実行使用メモリ | 7,424 KB |
最終ジャッジ日時 | 2024-12-22 10:05:28 |
合計ジャッジ時間 | 3,442 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#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