結果
| 問題 |
No.1265 Balloon Survival
|
| コンテスト | |
| ユーザー |
yamake
|
| 提出日時 | 2020-10-23 22:53:16 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 140 ms / 2,000 ms |
| コード長 | 1,497 bytes |
| コンパイル時間 | 1,088 ms |
| コンパイル使用メモリ | 97,904 KB |
| 実行使用メモリ | 15,840 KB |
| 最終ジャッジ日時 | 2024-07-21 12:03:33 |
| 合計ジャッジ時間 | 3,637 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define debug(output) cout<<#output<<"= "<<output<<endl
using lint=long long;
using P= pair<lint,lint>;
int MOD=1000000007;
lint d2(P& a,P& b){
return (a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second);
}
signed main(){
int n;cin>>n;
vector<pair<lint,lint>> b(n);
rep(i,n)cin>>b[i].first>>b[i].second;
priority_queue<pair<lint,P>,vector<pair<lint,P>>,greater<>> que;
rep(i,n){
for(int j=i+1;j<n;++j){
que.push({d2(b[i],b[j]),{i,j}});
}
}
vector<int> memo(n,0);
int res=0;
map<int,int> hoge;
lint dist=0;
while(!que.empty()){
auto buf=que.top();que.pop();
if(dist!=buf.first){
dist=buf.first;
for(auto& val:hoge){
memo[val.first]=1;
}
hoge.clear();
}
if(memo[buf.second.first]>0||memo[buf.second.second]>0){
continue;
}
if(buf.second.first==0||buf.second.second==0){
++res;
memo[buf.second.first+buf.second.second]=1;
}
else{
hoge[buf.second.first]=1;
hoge[buf.second.second]=1;
}
}
cout<<res<<"\n";
return 0;
}
yamake