結果

問題 No.202 1円玉投げ
ユーザー TatamoTatamo
提出日時 2016-10-06 14:06:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,640 ms / 5,000 ms
コード長 1,738 bytes
コンパイル時間 483 ms
コンパイル使用メモリ 66,772 KB
実行使用メモリ 8,584 KB
最終ジャッジ日時 2023-08-23 23:30:00
合計ジャッジ時間 11,287 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 458 ms
8,512 KB
testcase_01 AC 198 ms
8,248 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 7 ms
4,376 KB
testcase_06 AC 249 ms
6,972 KB
testcase_07 AC 307 ms
7,524 KB
testcase_08 AC 313 ms
7,488 KB
testcase_09 AC 113 ms
5,704 KB
testcase_10 AC 30 ms
4,380 KB
testcase_11 AC 82 ms
5,360 KB
testcase_12 AC 86 ms
5,412 KB
testcase_13 AC 34 ms
4,484 KB
testcase_14 AC 9 ms
4,380 KB
testcase_15 AC 105 ms
5,808 KB
testcase_16 AC 132 ms
8,584 KB
testcase_17 AC 1,144 ms
8,548 KB
testcase_18 AC 1,151 ms
8,584 KB
testcase_19 AC 96 ms
5,392 KB
testcase_20 AC 209 ms
6,696 KB
testcase_21 AC 93 ms
5,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 5 ms
4,376 KB
testcase_27 AC 5 ms
4,376 KB
testcase_28 AC 3 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 3 ms
4,380 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1,640 ms
8,580 KB
testcase_36 AC 197 ms
8,548 KB
testcase_37 AC 351 ms
7,788 KB
testcase_38 AC 1,611 ms
8,512 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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){
	if(a.x==b.x){
		return a.y < b.y;
	}
	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++){
				ll dx = cx - itr->x;
				ll dy = cy - itr->y;
				//DBG(dx);
				//DBG(dy);
				if(dx*dx + dy*dy < 20*20){
					//DBG(dx*dx+dy*dy);
					flg_collided = true;
					break;
				}
			}
			//DBG(flg_collided);
			if(!flg_collided) {
				field.insert(coins[i]);
			}
		}
	}
	cout << field.size() << endl;

	return 0;
}
0