結果

問題 No.2179 Planet Traveler
ユーザー lddlinanlddlinan
提出日時 2023-03-16 21:28:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,655 bytes
コンパイル時間 926 ms
コンパイル使用メモリ 102,652 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-18 13:13:13
合計ジャッジ時間 3,872 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 5 ms
4,348 KB
testcase_13 WA -
testcase_14 AC 72 ms
4,348 KB
testcase_15 AC 75 ms
4,348 KB
testcase_16 AC 66 ms
4,348 KB
testcase_17 AC 125 ms
4,348 KB
testcase_18 AC 113 ms
4,348 KB
testcase_19 AC 58 ms
4,348 KB
testcase_20 AC 19 ms
4,348 KB
testcase_21 AC 166 ms
4,348 KB
testcase_22 AC 92 ms
4,348 KB
testcase_23 AC 23 ms
4,348 KB
testcase_24 AC 83 ms
4,348 KB
testcase_25 AC 39 ms
4,348 KB
testcase_26 AC 28 ms
4,348 KB
testcase_27 AC 11 ms
4,348 KB
testcase_28 AC 26 ms
4,348 KB
testcase_29 AC 111 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <math.h>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <algorithm>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <string>
using namespace std;

bool rcmp(int a, int b) { return a>b; }
typedef long long LL;



int xs[804];
int ys[804];
int ts[804];
char mk[804];
int que[804];
char mp[804][804];
char check(LL r, int n) {
    int i, j, h, t;
    LL dd, dx, dy;
    double v;
    for (i=0; i<n; i++) {
        for (j=i+1; j<n; j++) {
            mp[i][j]=mp[j][i]=0;
            if (ts[i]==ts[j]) {
                dx=xs[i]-xs[j]; dy=ys[i]-ys[j];
                dd=dx*dx+dy*dy;
            } else {
                v=sqrt(xs[i]*xs[i]+ys[i]*ys[i]);
                v-=sqrt(xs[j]*xs[j]+ys[j]*ys[j]);
                dd=v*v;
                if (v*v-dd>1e-12) dd++;
            }
            if (dd<=r) mp[i][j]=mp[j][i]=1;
        } if (mp[0][n-1]) return 1;
    }
    for (i=0; i<n; i++) mk[i]=0;
    h=t=0; que[h++]=0; mk[0]=1;
    while(t<h) {
        i=que[t++];
        for (j=0; j<n; j++) if (j!=i&&mp[i][j]&&mk[j]==0) {
            mk[j]=1; que[h++]=j;
        }
    }
    return mk[n-1];
}

int main() {
    int n, i;
    LL r, nr, d;
    LL dx, dy;
    scanf("%d", &n);
    for (i=0; i<n; i++) scanf("%d %d %d", &xs[i], &ys[i], &ts[i]);
    dx=xs[0]-xs[n-1];
    dy=ys[0]-ys[n-1];
    r=-1; d=dx*dx+dy*dy;
    while(d) {
        while(1) {
            nr=r+d;
            if (check(nr, n)) break;
            r=nr;
        }
        d>>=1;
    }
    r++; printf("%lld\n", r);

    return 0;
}
0