結果

問題 No.202 1円玉投げ
ユーザー vain0vain0
提出日時 2015-06-01 02:01:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 88 ms / 5,000 ms
コード長 1,900 bytes
コンパイル時間 661 ms
コンパイル使用メモリ 94,060 KB
実行使用メモリ 5,232 KB
最終ジャッジ日時 2023-08-23 22:57:19
合計ジャッジ時間 2,976 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
4,432 KB
testcase_01 AC 38 ms
4,836 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 39 ms
4,772 KB
testcase_07 AC 44 ms
4,708 KB
testcase_08 AC 44 ms
4,776 KB
testcase_09 AC 24 ms
4,380 KB
testcase_10 AC 9 ms
4,376 KB
testcase_11 AC 19 ms
4,376 KB
testcase_12 AC 19 ms
4,380 KB
testcase_13 AC 11 ms
4,380 KB
testcase_14 AC 4 ms
4,376 KB
testcase_15 AC 22 ms
4,380 KB
testcase_16 AC 27 ms
4,440 KB
testcase_17 AC 35 ms
5,232 KB
testcase_18 AC 35 ms
4,996 KB
testcase_19 AC 20 ms
4,380 KB
testcase_20 AC 35 ms
4,620 KB
testcase_21 AC 21 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 32 ms
4,520 KB
testcase_36 AC 88 ms
4,380 KB
testcase_37 AC 46 ms
4,656 KB
testcase_38 AC 33 ms
4,592 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <functional>
#include <set>
#include <ctime>
#include <cmath>
#include <climits>
#include <string>
#include <queue>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#ifndef ONLINE_JUDGE //POJ
# include <random>
# include <array>
# define mkt make_tuple
# define empb emplace_back
#endif
#ifdef _LOCAL
# include "for_local.h"
#endif
using namespace std;
typedef unsigned int uint; typedef unsigned long long ull;
#define repi(_I, _B, _E) for(int _I = (_B); (_I) < (_E); ++ (_I))
#define rep(_I, _N) for(int _I = 0; (_I) < (_N); ++ (_I))
#define mkp make_pair
#define all(_X) (_X).begin(), (_X).end()
#define scani(_V) std::scanf("%d", &_V)
#define printi(_V) std::printf("%d", static_cast<int>(_V))

#include <list>
template<typename T>
T selfprod(T const& x, T const& y) { return x * x + y * y; }

int const INF = 1 << 29;
int const B = 40; //bucket size
vector<vector<pair<int,int>>> bs(20001 / B + 1);
bool conflict(int i, int x, int y) {
	if ( !(0 <= i && i < bs.size()) ) return false;
	auto& b = bs[i];
	auto lb = lower_bound(all(b), mkp(x - 20, 0));
	auto ub = upper_bound(all(b), mkp(x + 20, INF));
	for ( ; lb != ub; ++lb ) {
		auto& p = *lb;
		if ( selfprod(x - p.first, y - p.second) < 400 ) return true;
	}
	return false;
}
bool conflict(int x, int y) {
	int yl = max((y - 20) / B, 0);
	int yr = min((y + 20 + B - 1) / B, (int)bs.size());
	//assert(yr - yl <= 2);
	for ( int i = yl; i < yr; ++i ) {
		if ( conflict(i, x, y) ) return true;
	}
	return false;
}

signed main() {
	int n;
	scanf("%d", &n);

	int k = 0;
	rep(i, n) {
		int x, y;
		scanf("%d %d", &x, &y);
		if ( !conflict(x, y) ) {
			//bs[i]: y座標が [i*B, (i+1)*B) に入る点全体をもつ。x座標について整列済み。
			bs[y / B].emplace(lower_bound(all(bs[y / B]), mkp(x, y)), mkp(x, y));
			++k;
		}
	}
	printf("%d\n", k);
	return 0;
}
0