結果

問題 No.168 ものさし
ユーザー oevloevl
提出日時 2019-03-19 22:40:16
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,402 bytes
コンパイル時間 1,504 ms
コンパイル使用メモリ 168,760 KB
実行使用メモリ 11,256 KB
最終ジャッジ日時 2023-10-12 11:24:43
合計ジャッジ時間 15,224 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 OLE -
testcase_20 OLE -
testcase_21 OLE -
testcase_22 OLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = 0; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;

int N;
ll X[1000], Y[1000];
ll D[1000][1000];

class UnionFind{
public:
  vector<int> uni;
  UnionFind(int s) : uni(s, -1) {}

  int root(int a){
    if(uni[a] < 0) return a;
    return uni[a] = root(uni[a]);
  }

  bool connect(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;
    if(uni[a] > uni[b]) swap(a, b);
    uni[a] = uni[a] + uni[b];
    uni[b] = a;
    return true;
  }

  bool isConnect(int a, int b){
    return root(a) == root(b);
  }

  int size(int a){
    return -uni[root(a)];
  }
};

bool isOK(ll v) {
  UnionFind uf(1000);
  rep(i, 0, N) rep(j, 0, N) if(D[i][j] <= v * v * 100) uf.connect(i, j);
  return uf.isConnect(0, N - 1);
}

ll binary_search() {
  ll ng = 0;
  ll ok = 1e9;
  while(abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    if(isOK(mid)) ok = mid;
    else ng = mid;
  }
  return 10 * ok;
}

ll getDist(ll x, ll y, ll x2, ll y2) {
  return (x-x2) * (x-x2) + (y-y2) * (y-y2);
}

ll solve() {
  cin >> N;
  rep(i, 0, N) cin >> X[i] >> Y[i];
  rep(i, 0, N) rep(j, 0, N) D[i][j] = getDist(X[i], Y[i], X[j], Y[j]);
  rep(i, 0, N) rep(j, 0, N) cout << i << " " << j << " " << D[i][j] << endl;
  return binary_search();
}

int main(){
  cout << solve() <<endl;
  return 0;
}
0