結果
問題 | No.168 ものさし |
ユーザー |
![]() |
提出日時 | 2015-03-19 23:56:43 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,126 bytes |
コンパイル時間 | 578 ms |
コンパイル使用メモリ | 86,720 KB |
実行使用メモリ | 19,800 KB |
最終ジャッジ日時 | 2024-06-28 23:27:48 |
合計ジャッジ時間 | 1,385 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 18 WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:55:34: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=] 55 | printf("%d\n",pq_c.cost*10); return 0; | ~^ ~~~~~~~~~~~~ | | | | int long long int | %lld
ソースコード
#include<iostream> #include<cstdio> #include<algorithm> #include<vector> #include<string> #include<cstring> #include<climits> #include<functional> #include<map> #include<set> #include<queue> #include<cmath> using namespace std; #define int long long #define EPS 1e-10 struct Point{ int x,y; Point(){} Point(int _x,int _y){ x=_x; y=_y; } Point operator-(const Point &a)const{ return Point(a.x-x,a.y-y); } int norm(){ return x*x+y*y; } }; struct Data{ int n,cost; Data(){} Data(int _n,int _cost){ n=_n; cost=_cost; } bool operator<(const Data &a)const{ return cost>a.cost; } }; signed main(){ int N; Point P[1000]; cin>>N; for(int i=0;i<N;i++){ cin>>P[i].x>>P[i].y; } priority_queue<Data> pq; pq.push(Data(0,0)); Data pq_c; bool memo[1000] = {}; while(!pq.empty()){ pq_c = pq.top(); pq.pop(); if(pq_c.n==N-1){ printf("%d\n",pq_c.cost*10); return 0; } if(memo[pq_c.n]) continue; memo[pq_c.n] = true; for(int i=0;i<N;i++){ if(pq_c.n==i) continue; int cost = (sqrt((P[i]-P[pq_c.n]).norm())-EPS)/10.0; cost++; pq.push(Data(i,max(pq_c.cost,cost))); } } return 0; }