結果

問題 No.168 ものさし
ユーザー fura
提出日時 2020-06-09 02:37:46
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 993 bytes
コンパイル時間 2,166 ms
コンパイル使用メモリ 206,308 KB
最終ジャッジ日時 2025-01-11 00:18:23
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:27:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 |         int n; scanf("%d",&n);
      |                ~~~~~^~~~~~~~~
main.cpp:29:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   29 |         rep(i,n) scanf("%lld%lld",&x[i],&y[i]);
      |                  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using lint=long long;
class union_find{
int n;
vector<int> p;
public:
union_find(int n):n(n),p(n,-1){}
int find(int u){ return p[u]<0?u:p[u]=find(p[u]); }
void unite(int u,int v){
u=find(u); v=find(v);
if(u!=v){
if(p[v]<p[u]) swap(u,v);
p[u]+=p[v]; p[v]=u; n--;
}
}
bool is_same(int u,int v){ return find(u)==find(v); }
int size()const{ return n; }
int size(int u){ return -p[find(u)]; }
};
int main(){
int n; scanf("%d",&n);
vector<lint> x(n),y(n);
rep(i,n) scanf("%lld%lld",&x[i],&y[i]);
vector<tuple<lint,int,int>> E;
rep(i,n) rep(j,i) {
E.emplace_back((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]),i,j);
}
sort(E.begin(),E.end());
union_find U(n);
for(const auto& e:E){
U.unite(get<1>(e),get<2>(e));
if(U.is_same(0,n-1)){
lint ans=lint(sqrt(get<0>(e))-0.1)/10*10;
while(ans*ans<get<0>(e)) ans+=10;
printf("%lld\n",ans);
break;
}
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0