結果

問題 No.2179 Planet Traveler
ユーザー lddlinanlddlinan
提出日時 2023-03-16 21:51:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,739 bytes
コンパイル時間 753 ms
コンパイル使用メモリ 86,612 KB
実行使用メモリ 8,328 KB
最終ジャッジ日時 2023-10-18 13:14:21
合計ジャッジ時間 3,708 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 3 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 7 ms
8,308 KB
testcase_15 AC 7 ms
8,308 KB
testcase_16 AC 7 ms
8,308 KB
testcase_17 AC 187 ms
8,308 KB
testcase_18 AC 186 ms
8,308 KB
testcase_19 AC 184 ms
8,308 KB
testcase_20 AC 27 ms
5,116 KB
testcase_21 AC 173 ms
8,116 KB
testcase_22 AC 113 ms
7,208 KB
testcase_23 AC 100 ms
6,964 KB
testcase_24 AC 151 ms
7,820 KB
testcase_25 AC 119 ms
7,312 KB
testcase_26 AC 166 ms
8,028 KB
testcase_27 AC 27 ms
5,152 KB
testcase_28 AC 80 ms
6,568 KB
testcase_29 AC 152 ms
7,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<string.h>
#include<stdlib.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];
LL dis[804][804];
LL xd[804];
LL inf;
LL mysqrt(LL v) {
    LL r=0, nr;
    LL d=1; d<<=30;
    while(d) {
        while(1) {
            nr=r+d;
            if (inf/nr<=nr) break;
            if (nr*nr>v) break;
            r=nr;
        }
        d>>=1;
    }
    return r;
}

int main() {
    int n, i, mi, j;
    LL r, nr, d, md;
    LL dx, dy, dd;
    double v;
    inf=1; inf<<=61;
    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];
    d=dx*dx+dy*dy;
    for (i=0; i<n; i++) {
        for (j=i+1; j<n; j++) {
            if (ts[i]==ts[j]) {
                dx=xs[i]-xs[j]; dy=ys[i]-ys[j];
                dd=dx*dx+dy*dy;
            } else {
                dx=xs[i]*xs[i]+ys[i]*ys[i];
                dy=xs[j]*xs[j]+ys[j]*ys[j];
                dd=mysqrt(dx*dy*4); // <=
                dd=dx+dy-dd;
            }
            dis[i][j]=dis[j][i]=dd;
        }
    }
    for (i=0; i<n; i++) { xd[i]=d+1; mk[i]=0; } xd[0]=0;
    r=0;
    while(1) {
        md=d+1; mi=-1;
        for (i=0; i<n; i++) if (mk[i]==0&&md>xd[i]) { md=xd[i]; mi=i; }
        if (mi==-1) break;
        r=max(r, md); if (mi==n-1) break;
        mk[mi]=1;
        for (i=0; i<n; i++) if (mk[i]==0) xd[i]=min(xd[i], dis[mi][i]);
    }
    printf("%lld\n", r);

    return 0;
}
0