結果

問題 No.202 1円玉投げ
ユーザー kurenai3110
提出日時 2017-03-14 22:36:11
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,393 bytes
コンパイル時間 847 ms
コンパイル使用メモリ 74,764 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-22 10:55:42
合計ジャッジ時間 7,631 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int dist(pair<int, int>a, pair<int, int>b) {
	return (a.first - b.first)*(a.first - b.first) + (a.second - b.second)*(a.second - b.second);
}

int main()
{
	int n;cin >> n;
	vector<pair<pair<int, int>, int>>sorted_pos;
	vector<pair<int, int>>pos;
	for (int i = 0;i < n;i++) {
		int x, y;cin >> x >> y;
		pos.push_back(make_pair(x, y));
		sorted_pos.push_back(make_pair(make_pair(x, y), i));
	}
	sort(sorted_pos.begin(), sorted_pos.end());

	vector<int>sorted_index(n);
	for (int i = 0;i < n;i++) {
		sorted_index[sorted_pos[i].second] = i;
	}

	vector<bool>exist(n, true);

	for (int i = 0;i < n;i++) {
		int pos = sorted_index[i];
		if (exist[pos] == false)continue;

		for (int j = pos + 1;j < sorted_pos.size();j++) {
			if (exist[j] == false)break;
			if (dist(sorted_pos[j].first, sorted_pos[pos].first) >= 400) {
				if (sorted_pos[j].first.first - sorted_pos[pos].first.first > 20)break;
				continue;
			}
			else exist[j] = false;
		}
		for (int j = pos - 1;j >= 0;j--) {
			if (exist[j] == false)break;
			if (dist(sorted_pos[j].first, sorted_pos[pos].first) >= 400) {
				if (sorted_pos[pos].first.first - sorted_pos[j].first.first > 20)break;
				continue;
			}
			else exist[j] = false;
		}
	}

	int cnt = 0;
	for (int i = 0;i < n;i++) {
		if (exist[i])cnt++;
	}

	cout << cnt << endl;

	return 0;
}
0