結果

問題 No.2179 Planet Traveler
ユーザー 👑 kmjpkmjp
提出日時 2023-01-06 23:22:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,577 bytes
コンパイル時間 1,980 ms
コンパイル使用メモリ 202,904 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2024-05-07 23:14:40
合計ジャッジ時間 19,944 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1,216 ms
8,572 KB
testcase_15 AC 1,206 ms
8,548 KB
testcase_16 AC 1,220 ms
8,516 KB
testcase_17 AC 1,237 ms
8,456 KB
testcase_18 AC 1,389 ms
8,576 KB
testcase_19 AC 1,234 ms
8,532 KB
testcase_20 AC 54 ms
5,376 KB
testcase_21 AC 1,132 ms
8,320 KB
testcase_22 AC 557 ms
7,424 KB
testcase_23 AC 454 ms
7,068 KB
testcase_24 AC 881 ms
8,064 KB
testcase_25 AC 623 ms
7,552 KB
testcase_26 AC 1,049 ms
8,192 KB
testcase_27 AC 57 ms
5,376 KB
testcase_28 AC 328 ms
6,784 KB
testcase_29 AC 918 ms
8,064 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=29;i>=0;i--) {
		ll s2=s-(1<<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