結果

問題 No.202 1円玉投げ
ユーザー TatamoTatamo
提出日時 2016-10-04 18:44:25
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,770 bytes
コンパイル時間 604 ms
コンパイル使用メモリ 67,892 KB
実行使用メモリ 8,464 KB
最終ジャッジ日時 2023-08-23 23:28:52
合計ジャッジ時間 10,714 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<utility>
#include<vector>
#include<set>

using namespace std;
#define cerr cerr << "[DBG] "  
#define DBG(x) cerr << #x << ": " << x << endl
// http://genkisugimoto.com/jp/blog/procon/2015/04/15/print-debug-technique-in-cpp.html
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { s << v[i]; if (i < v.size() - 1) s << "\t"; } return s; }

typedef long long ll;

struct Coin{
	int x;
	int y;
};

// for set
bool operator<(const Coin &a, const Coin &b){
	return a.x < b.x;
}

// for binary_search
struct CoinOpr{
	bool operator()(const Coin* a, const Coin* b){
		return a->x < b->x;
	}
};

typedef set<Coin>::iterator CSItr;

// yukicoder problems/476 No.202
int main(){
	int n;
	cin >> n;
	vector<Coin> coins(n);
	for(int i=0; i<n; i++){
		Coin c;
		cin >> c.x >> c.y;
		coins[i] = c;
	}
	set<Coin> field;
	for(int i=0; i<n; i++){
		DBG(i);
		int cx = coins[i].x;
		int cy = coins[i].y;
		if(field.empty()){
			field.insert(coins[i]);
		}
		else{
			Coin low, up;
			low.x = cx-20;
			low.y = cy;
			up.x = cx+20;
			up.y = cy;
			cerr << "low: " << low.x << "," << low.y << endl;
			CSItr begin = field.lower_bound(low);
			CSItr end = field.upper_bound(up);
			bool flg_collided = false; // true : not collided
			for(CSItr itr = begin; itr!=end; itr++){
				int dx = cx - itr->x;
				int dy = cy - itr->y;
				DBG(dx);
				DBG(dy);
				if(dx*dx + dy*dy < 20*20){
					flg_collided = true;
					break;
				}
			}
			DBG(flg_collided);
			if(!flg_collided) field.insert(coins[i]);
		}
	}
	cout << field.size() << endl;

	return 0;
}
0