結果
| 問題 |
No.202 1円玉投げ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-05-12 02:59:19 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 619 ms / 5,000 ms |
| コード長 | 724 bytes |
| コンパイル時間 | 807 ms |
| コンパイル使用メモリ | 52,480 KB |
| 実行使用メモリ | 10,112 KB |
| 最終ジャッジ日時 | 2024-12-22 09:03:16 |
| 合計ジャッジ時間 | 7,123 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:31:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::set<std::pair<int, int> >::size_type’ {aka ‘long unsigned int’} [-Wformat=]
31 | printf("%d\n",se.size());
| ~^ ~~~~~~~~~
| | |
| int std::set<std::pair<int, int> >::size_type {aka long unsigned int}
| %ld
main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%d",&N);
| ~~~~~^~~~~~~~~
main.cpp:14:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
14 | scanf("%d%d",&x,&y);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#include <vector>
#include <set>
#include <cstdio>
using namespace std;
typedef pair<int,int> pii;
int main(){
int N;
scanf("%d",&N);
vector<pair<int,int> >v(N);
set<int>kindx,kindy;
for(int i=0;i<N;i++){
int x,y;
scanf("%d%d",&x,&y);
v[i]={x,y};
kindx.insert(x),kindy.insert(y);
}
//x must be more sparse (wide) than y
if(kindx.size()<kindy.size())for(int i=0;i<N;i++)swap(v[i].first,v[i].second);
set<pii>se;
for(int i=0;i<N;i++){
int x=v[i].first,y=v[i].second;
pii A={x-20,0},B={x+20,1<<30};
auto a=se.lower_bound(A),b=se.upper_bound(B);
for(;a!=b;++a){
if((a->first-x)*(a->first-x) + (a->second-y)*(a->second-y) < 400)break;
}
if(a==b)se.insert({x,y});
}
printf("%d\n",se.size());
}