結果

問題 No.202 1円玉投げ
ユーザー masamasa
提出日時 2015-05-05 22:24:32
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 731 ms / 5,000 ms
コード長 912 bytes
コンパイル時間 595 ms
コンパイル使用メモリ 69,728 KB
実行使用メモリ 53,024 KB
最終ジャッジ日時 2023-08-23 22:26:52
合計ジャッジ時間 13,700 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 495 ms
52,872 KB
testcase_01 AC 731 ms
52,708 KB
testcase_02 AC 43 ms
52,872 KB
testcase_03 AC 42 ms
52,720 KB
testcase_04 AC 42 ms
52,836 KB
testcase_05 AC 86 ms
52,872 KB
testcase_06 AC 607 ms
52,708 KB
testcase_07 AC 662 ms
52,892 KB
testcase_08 AC 670 ms
52,752 KB
testcase_09 AC 400 ms
52,828 KB
testcase_10 AC 192 ms
52,944 KB
testcase_11 AC 340 ms
52,812 KB
testcase_12 AC 348 ms
52,756 KB
testcase_13 AC 211 ms
52,712 KB
testcase_14 AC 93 ms
52,824 KB
testcase_15 AC 387 ms
52,816 KB
testcase_16 AC 468 ms
52,716 KB
testcase_17 AC 458 ms
52,940 KB
testcase_18 AC 459 ms
52,712 KB
testcase_19 AC 371 ms
52,748 KB
testcase_20 AC 547 ms
52,836 KB
testcase_21 AC 362 ms
52,904 KB
testcase_22 AC 45 ms
52,712 KB
testcase_23 AC 46 ms
52,748 KB
testcase_24 AC 45 ms
53,024 KB
testcase_25 AC 45 ms
52,892 KB
testcase_26 AC 46 ms
52,892 KB
testcase_27 AC 46 ms
52,820 KB
testcase_28 AC 44 ms
53,000 KB
testcase_29 AC 45 ms
52,756 KB
testcase_30 AC 49 ms
52,716 KB
testcase_31 AC 44 ms
52,952 KB
testcase_32 AC 50 ms
52,940 KB
testcase_33 AC 46 ms
52,944 KB
testcase_34 AC 46 ms
52,820 KB
testcase_35 AC 457 ms
52,892 KB
testcase_36 AC 459 ms
52,752 KB
testcase_37 AC 707 ms
52,708 KB
testcase_38 AC 464 ms
52,712 KB
testcase_39 AC 43 ms
52,820 KB
testcase_40 AC 44 ms
52,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

const int XY_MAX = 20000;
const int R = 10;
const int LEN = 2 * R;
const int LEN2 = LEN * LEN;

vector< vector<bool> > board;

bool possible(int x, int y) {
	int dx, dy, nx, ny;
	for (dx = -LEN; dx <= LEN; dx++) {
		nx = x + dx;
		if (nx < 0 || XY_MAX < nx) {
			continue;
		}

		for (dy = -LEN; dy <= LEN; dy++) {
			ny = y + dy;
			if (ny < 0 || XY_MAX < ny) {
				continue;
			}

			if (dx * dx + dy * dy >= LEN2) {
				continue;
			}

			if (board[ny][nx]) {
				return false;
			}
		}
	}
	return true;
}

int main() {
	int n, x, y;
	board.assign(XY_MAX + 1, vector<bool>(XY_MAX + 1, false));

	cin >> n;
	int coin = 0;
	for (int i = 0; i < n; i++) {
		cin >> x >> y;

		if (possible(x, y)) {
			coin++;
			board[y][x] = true;
		}
	}

	cout << coin << endl;
	return 0;
}
0