結果

問題 No.202 1円玉投げ
ユーザー kurenai3110kurenai3110
提出日時 2017-03-14 21:53:41
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,194 bytes
コンパイル時間 638 ms
コンパイル使用メモリ 76,416 KB
実行使用メモリ 5,512 KB
最終ジャッジ日時 2023-08-23 23:31:09
合計ジャッジ時間 3,383 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
5,364 KB
testcase_01 AC 59 ms
5,328 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 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 AC 52 ms
5,356 KB
testcase_17 AC 59 ms
5,432 KB
testcase_18 AC 61 ms
5,340 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 58 ms
5,344 KB
testcase_36 AC 63 ms
5,324 KB
testcase_37 WA -
testcase_38 AC 65 ms
5,512 KB
testcase_39 AC 1 ms
4,380 KB
testcase_40 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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(pos.begin(), 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)break;
			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)break;
			else exist[j] = false;
		}
	}

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

	cout << cnt << endl;

    return 0;
}
0