結果

問題 No.2179 Planet Traveler
ユーザー 👑 kmjpkmjp
提出日時 2023-01-06 23:23:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 898 ms / 3,000 ms
コード長 1,579 bytes
コンパイル時間 2,233 ms
コンパイル使用メモリ 201,036 KB
実行使用メモリ 8,640 KB
最終ジャッジ日時 2023-08-20 16:53:53
合計ジャッジ時間 14,857 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 821 ms
8,436 KB
testcase_12 AC 857 ms
8,496 KB
testcase_13 AC 819 ms
8,492 KB
testcase_14 AC 856 ms
8,640 KB
testcase_15 AC 844 ms
8,448 KB
testcase_16 AC 880 ms
8,444 KB
testcase_17 AC 860 ms
8,636 KB
testcase_18 AC 898 ms
8,508 KB
testcase_19 AC 894 ms
8,424 KB
testcase_20 AC 41 ms
5,268 KB
testcase_21 AC 821 ms
8,372 KB
testcase_22 AC 414 ms
7,468 KB
testcase_23 AC 327 ms
7,488 KB
testcase_24 AC 618 ms
7,944 KB
testcase_25 AC 441 ms
7,488 KB
testcase_26 AC 779 ms
8,264 KB
testcase_27 AC 44 ms
5,240 KB
testcase_28 AC 236 ms
7,612 KB
testcase_29 AC 668 ms
7,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N;
ll X[805],Y[805],T[805];
ll D[808][808];

ll issq(ll V) {
	return V;
	if(V<0) return -1;
	ll a=sqrt(V);
	if((a-1)*(a-1)>=V) return a-1;
	if(a*a>=V) return a;
	if((a+1)*(a+1)>=V) return a+1;
	return -1;
}

ll hoge(ll p,ll q) {
	if(p==q) return 0;
	ll s=p+q;
	int i;
	for(i=40;i>=0;i--) {
		ll s2=s-(1LL<<i);
		if(s2<0) continue;
		if((p+q-s2)*(p+q-s2)<=4*p*q) s=s2;
	}
	return s;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>X[i]>>Y[i]>>T[i];
	FOR(y,N) FOR(x,y) {
		if(T[x]==T[y]) {
			D[y][x]=issq((X[x]-X[y])*(X[x]-X[y])+(Y[x]-Y[y])*(Y[x]-Y[y]));
		}
		else {
			D[y][x]=hoge(X[x]*X[x]+Y[x]*Y[x],X[y]*X[y]+Y[y]*Y[y]);
		}
		D[x][y]=D[y][x];
	}
	FOR(k,N) FOR(x,N) FOR(y,N) D[x][y]=min(D[x][y],max(D[x][k],D[k][y]));
	cout<<D[0][N-1]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0