結果
問題 | No.2179 Planet Traveler |
ユーザー |
|
提出日時 | 2023-03-16 21:38:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,447 bytes |
コンパイル時間 | 866 ms |
コンパイル使用メモリ | 101,468 KB |
最終ジャッジ日時 | 2025-02-11 12:00:40 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 WA * 19 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:35:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 35 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:36:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 36 | 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]; LL dis[804][804]; LL xd[804]; int main() { int n, i, mi, j; LL r, nr, d, md; LL dx, dy, dd; double v; 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 { 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++; } dis[i][j]=dis[j][i]=dd; } } for (i=0; i<n; i++) { xd[i]=d+1; mk[i]=0; } xd[0]=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; mk[mi]=1; for (i=0; i<n; i++) if (mk[i]==0) xd[i]=min(xd[i], dis[mi][i]); } printf("%lld\n", xd[n-1]); return 0; }