結果

問題 No.202 1円玉投げ
ユーザー TatamoTatamo
提出日時 2016-10-04 18:47:51
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,666 bytes
コンパイル時間 499 ms
コンパイル使用メモリ 67,084 KB
実行使用メモリ 5,156 KB
最終ジャッジ日時 2023-08-23 23:28:56
合計ジャッジ時間 3,686 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 2 ms
4,380 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){
	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