結果

問題 No.168 ものさし
ユーザー tea_pt
提出日時 2015-06-12 20:50:50
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 204 ms / 2,000 ms
コード長 2,365 bytes
コンパイル時間 838 ms
コンパイル使用メモリ 91,704 KB
実行使用メモリ 11,224 KB
最終ジャッジ日時 2024-12-24 07:09:30
合計ジャッジ時間 2,765 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

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

#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <stack>
#include <array>
#include <fstream>
#include <complex>
#define REP(i,n) for(int (i) = 0;(i) < (n) ; ++(i))
#define REPS(a,i,n) for(int (i) = (a) ; (i) < (n) ; ++(i))
#if defined(_MSC_VER)||__cplusplus > 199711L
#define AUTO(r,v) auto r = (v)
#else
#define AUTO(r,v) typeof(v) r = (v)
#endif
#define ALL(c) (c).begin() , (c).end()
#define EACH(it,c) for(AUTO(it,(c).begin());it != (c).end();++it)
#define LL long long
#define int LL
#define INF 999999999999
#define DEV 1000000007
#define QUICK_CIN ios::sync_with_stdio(false); cin.tie(0);
using namespace std;
class UnionFind{
public:
//n
UnionFind(int n) :
par(n),
rank(n)
{
for (int i = 0; i < n; ++i){
par[i] = i;
}
}
//xy
void unite(int x, int y){
x = find(x);
y = find(y);
if (x == y)return;
if (rank.at(x) < rank.at(y)){
par.at(x) = y;
}
else{
par.at(y) = x;
if (rank.at(x) == rank.at(y))rank.at(x)++;
}
}
bool same(int x, int y){
return find(x) == find(y);
}
private:
//
vector<int> par;
//
vector<int> rank;
//
int find(int x){
if (par.at(x) == x){
return x;
}
else{
return par.at(x) = find(par.at(x));
}
}
};
int d[1002][1002];
complex<int> p[1002];
int n;
bool solve(int mu){
UnionFind uf(n);
REP(i, n){
REP(j, n){
if (d[i][j] <= mu ){
uf.unite(i, j);
}
}
}
return uf.same(0, n - 1);
}
signed main()
{
QUICK_CIN;
//ifstream cin("debug.txt");
//ofstream cout("result.txt");
cin >> n;
REP(i, n){
int x, y;
cin >> x >> y;
p[i] = { (int)x, (int)y };
}
REP(i, n){
REP(j, n){
d[i][j] = norm(p[i] - p[j]);
}
}
int left, midle, right;
left = 0;
right = 20000000000;
REP(i, 100){
midle = (left + right) / 2;
if (!solve(midle*midle)){
left = midle;
}
else{
right = midle+1;
}
}
int temp = midle*10;
int ans = (temp + 10*(temp % 10 != 0))/10;
ans += 10*(ans % 10 != 0) - (ans % 10);
cout << ans << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0