結果
| 問題 |
No.202 1円玉投げ
|
| コンテスト | |
| ユーザー |
vain0
|
| 提出日時 | 2015-06-01 01:41:34 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,745 bytes |
| コンパイル時間 | 1,083 ms |
| コンパイル使用メモリ | 86,468 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-22 09:22:56 |
| 合計ジャッジ時間 | 6,179 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 RE * 23 |
コンパイルメッセージ
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);
| ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#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;
}
vain0