結果
問題 | No.1265 Balloon Survival |
ユーザー |
|
提出日時 | 2020-10-24 00:07:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 115 ms / 2,000 ms |
コード長 | 1,105 bytes |
コンパイル時間 | 1,942 ms |
コンパイル使用メモリ | 203,664 KB |
最終ジャッジ日時 | 2025-01-15 14:32:15 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <math.h> #include <iomanip> #include <cstdint> #define rep(i,n) for (int i = 0; i < (n); ++i) using ll = long long; using P = pair<int,int>; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const int INF=1001001001; const int mod=1000000007; int main() { int N; cin>>N; vector<int>x(N),y(N); for(int i=0;i<N;i++){ cin>>x[i]>>y[i]; } priority_queue<pair<int64_t,pair<int,int>>>q; for(int i=0;i<N;i++){ for(int j=i+1;j<N;j++){ int64_t dx=x[j]-x[i],dy=y[j]-y[i]; int64_t dis=dx*dx+dy*dy; q.push(make_pair(-dis,make_pair(i,j))); } } vector<bool>seen(N,false); int cnt=0; while(!q.empty()){ int d=q.top().first,i=q.top().second.first,j=q.top().second.second; q.pop(); if(i==0||j==0){ if(!seen[i+j-0]){cnt++;seen[i+j-0]=true;}//i+j-0=0の相方 } else if(!seen[i]&&!seen[j]){seen[i]=true;seen[j]=true;} } cout<<cnt<<endl; return 0; }