結果
| 問題 | No.2179 Planet Traveler |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-03-16 21:28:30 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,655 bytes |
| 記録 | |
| コンパイル時間 | 884 ms |
| コンパイル使用メモリ | 99,752 KB |
| 最終ジャッジ日時 | 2025-02-11 12:00:31 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 25 WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:63:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
63 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:64:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
64 | for (i=0; i<n; i++) scanf("%d %d %d", &xs[i], &ys[i], &ts[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#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;
}