結果
| 問題 |
No.2179 Planet Traveler
|
| コンテスト | |
| ユーザー |
MasKoaTS
|
| 提出日時 | 2022-09-06 20:27:28 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,179 bytes |
| コンパイル時間 | 4,394 ms |
| コンパイル使用メモリ | 258,148 KB |
| 最終ジャッジ日時 | 2025-02-07 03:14:51 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 8 WA * 18 |
ソースコード
#include <math.h>
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, l, n) for (int i = (l); i < (n); i++)
#define squ(n) (n) * (n)
using namespace std;
using namespace atcoder;
using ll = long long;
using u64 = unsigned long long;
template <class T> using V = vector<T>;
u64 isqrt(u64 n) {
u64 ok = 0ll;
u64 ng = 4000000000ll;
while (ng - ok > 1ll) {
u64 mid = (ok + ng) >> 1ll;
if (mid * mid <= n) {
ok = mid;
}
else {
ng = mid;
}
}
return ok;
}
int main(void) {
int n; cin >> n;
V<V<ll> > p(n, V<ll>(3));
rep(i, 0, n) {
ll x, y, t; cin >> x >> y >> t;
p[i] = { x,y,t };
}
V<V<u64> > dist(n, V<u64>(n, 1000000000000000000ll));
rep(i, 0, n-1) {
dist[i][i] = 0;
u64 r1 = (u64)(squ(p[i][0]) + squ(p[i][1]));
rep(j, i + 1, n) {
u64 r2 = (u64)(squ(p[j][0]) + squ(p[j][1]));
dist[i][j] = (u64)(squ(p[i][0] - p[j][0]) + squ(p[i][1] - p[j][1]));
if (p[i][2] != p[j][2]) {
dist[i][j] = r1 + r2 - isqrt(4ll * r1 * r2);
}
}
}
rep(k, 0, n) {
rep(i, 0, n) {
rep(j, 0, n) {
dist[i][j] = min(dist[i][j], max(dist[i][k], dist[k][j]));
}
}
}
u64 ans = dist[0][n - 1];
cout << ans << endl;
return 0;
}
MasKoaTS