結果

問題 No.202 1円玉投げ
ユーザー vain0vain0
提出日時 2015-06-01 01:41:34
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,745 bytes
コンパイル時間 801 ms
コンパイル使用メモリ 86,304 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-01 20:23:33
合計ジャッジ時間 4,572 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 4 ms
6,944 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 4 ms
6,940 KB
testcase_15 RE -
testcase_16 AC 29 ms
6,944 KB
testcase_17 AC 30 ms
6,940 KB
testcase_18 AC 26 ms
6,940 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 2 ms
6,940 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 2 ms
6,940 KB
testcase_27 RE -
testcase_28 AC 1 ms
6,944 KB
testcase_29 RE -
testcase_30 RE -
testcase_31 AC 2 ms
6,944 KB
testcase_32 AC 2 ms
6,944 KB
testcase_33 RE -
testcase_34 AC 2 ms
6,940 KB
testcase_35 AC 29 ms
6,944 KB
testcase_36 RE -
testcase_37 RE -
testcase_38 AC 29 ms
6,944 KB
testcase_39 AC 2 ms
6,940 KB
testcase_40 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:62:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   62 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
main.cpp:67:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   67 |                 scanf("%d %d", &x, &y);
      |                 ~~~~~^~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <cassert>
#include <functional>
#include <set>
#include <ctime>
#include <cmath>
#include <climits>
#include <string>
#include <queue>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#ifndef ONLINE_JUDGE //POJ
# include <random>
# include <array>
# define mkt make_tuple
# define empb emplace_back
#endif
#ifdef _LOCAL
# include "for_local.h"
#endif
using namespace std;
typedef unsigned int uint; typedef unsigned long long ull;
#define repi(_I, _B, _E) for(int _I = (_B); (_I) < (_E); ++ (_I))
#define rep(_I, _N) for(int _I = 0; (_I) < (_N); ++ (_I))
#define mkp make_pair
#define all(_X) (_X).begin(), (_X).end()
#define scani(_V) std::scanf("%d", &_V)
#define printi(_V) std::printf("%d", static_cast<int>(_V))

#include <list>
template<typename T>
T selfprod(T const& x, T const& y) { return x * x + y * y; }

int const B = 10;
vector<vector<pair<int,int>>> board(20000 / B);

bool conflict(int i, int x, int y) {
	if ( !(0 <= i && i < board.size()) ) return false;
	auto& b = board[i];
	auto lb = lower_bound(all(b), mkp(x - 20, y - 20));
	auto ub = upper_bound(all(b), mkp(x + 20, y + 20));
	for ( ; lb != ub; ++lb ) {
		auto& p = *lb;
		if ( selfprod(x - p.first, y - p.second) < 400 ) return true;
	}
	return false;
}
bool conflict(int x, int y) {
	int yl = (y - 20) / B;
	int yr = min<int>(board.size(), (y + 20 + B - 1) / B);
	for ( int i = yl; i < yr; ++i ) {
		if ( conflict(i, x, y) ) return true;
	}
	return false;
}

signed main() {
	int n;
	scanf("%d", &n);

	int k = 0;
	rep(i, n) {
		int x, y;
		scanf("%d %d", &x, &y);
		if ( !conflict(x, y) ) {
			board[y/ B].emplace(lower_bound(all(board[y/B]), mkp(x, y)), mkp(x, y));
			++k;
		}
	}
	printf("%d\n", k);
	return 0;
}
0