結果
問題 | No.168 ものさし |
ユーザー | yaoshimax |
提出日時 | 2015-03-20 00:15:08 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 74 ms / 2,000 ms |
コード長 | 1,823 bytes |
コンパイル時間 | 794 ms |
コンパイル使用メモリ | 99,496 KB |
実行使用メモリ | 19,336 KB |
最終ジャッジ日時 | 2023-08-25 20:43:51 |
合計ジャッジ時間 | 2,351 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 19 ms
7,044 KB |
testcase_01 | AC | 2 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 | 1 ms
4,380 KB |
testcase_06 | AC | 1 ms
4,376 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 2 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,380 KB |
testcase_10 | AC | 3 ms
4,376 KB |
testcase_11 | AC | 17 ms
6,740 KB |
testcase_12 | AC | 53 ms
16,592 KB |
testcase_13 | AC | 74 ms
19,272 KB |
testcase_14 | AC | 73 ms
19,280 KB |
testcase_15 | AC | 1 ms
4,380 KB |
testcase_16 | AC | 1 ms
4,376 KB |
testcase_17 | AC | 2 ms
4,380 KB |
testcase_18 | AC | 5 ms
4,376 KB |
testcase_19 | AC | 71 ms
18,820 KB |
testcase_20 | AC | 73 ms
19,200 KB |
testcase_21 | AC | 74 ms
19,156 KB |
testcase_22 | AC | 74 ms
19,336 KB |
ソースコード
#include <cstdio> #include <queue> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include <queue> #include <cstring> using namespace std; int main(){ int N; cin >> N; pair<long long ,long long> points[N]; for( int i = 0 ; i <N; i++ ){ cin >> points[i].first>> points[i].second; } vector<pair<long long,int> > edge[N]; for( int i = 0; i<N;i++){ for( int j = 0 ; j <N ; j++ ){ if( i==j ) continue; long long dx=points[i].first-points[j].first; long long dy=points[i].second-points[j].second; edge[i].push_back( make_pair(dx*dx+dy*dy,j) ); } } for(int i=0;i<N;i++){ sort(edge[i].begin(),edge[i].end()); } long long left = 0; long long right = 200000000; while( left+1 < right){ long long mid=(left+right)/2; long long dist = mid*10; bool arrived[N]; memset(arrived,false,sizeof(arrived)); stack<int> q; q.push(0); arrived[0]=true; bool ok = false; while(ok==false&&!q.empty()){ int cur = q.top(); q.pop(); for( int i = 0; i <N-1 ; i++ ){ if( edge[cur][i].first > dist*dist ) break; if( arrived[edge[cur][i].second] ) continue; if( edge[cur][i].second == N-1){ ok=true; break; } arrived[edge[cur][i].second]=true; q.push(edge[cur][i].second); } } if( ok ){ right = mid; } else{ left = mid; } } cout << right*10; return 0; }