結果
問題 | No.1069 電柱 / Pole (Hard) |
ユーザー | 👑 kmjp |
提出日時 | 2022-11-10 23:55:26 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,937 bytes |
コンパイル時間 | 2,783 ms |
コンパイル使用メモリ | 227,784 KB |
実行使用メモリ | 37,208 KB |
最終ジャッジ日時 | 2023-10-09 20:54:57 |
合計ジャッジ時間 | 7,734 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
9,988 KB |
testcase_01 | AC | 3 ms
10,128 KB |
testcase_02 | AC | 3 ms
10,144 KB |
testcase_03 | AC | 4 ms
10,008 KB |
testcase_04 | AC | 452 ms
30,128 KB |
testcase_05 | AC | 691 ms
37,008 KB |
testcase_06 | AC | 27 ms
25,992 KB |
testcase_07 | AC | 21 ms
25,988 KB |
testcase_08 | WA | - |
testcase_09 | AC | 34 ms
25,964 KB |
testcase_10 | AC | 39 ms
28,300 KB |
testcase_11 | AC | 5 ms
12,988 KB |
testcase_12 | AC | 5 ms
10,800 KB |
testcase_13 | AC | 8 ms
12,828 KB |
testcase_14 | AC | 7 ms
12,912 KB |
testcase_15 | WA | - |
testcase_16 | AC | 17 ms
19,384 KB |
testcase_17 | WA | - |
testcase_18 | AC | 15 ms
17,148 KB |
testcase_19 | AC | 24 ms
21,484 KB |
testcase_20 | WA | - |
testcase_21 | AC | 10 ms
10,396 KB |
testcase_22 | AC | 6 ms
10,320 KB |
testcase_23 | AC | 25 ms
10,376 KB |
testcase_24 | AC | 55 ms
32,464 KB |
testcase_25 | AC | 55 ms
32,496 KB |
testcase_26 | AC | 30 ms
32,492 KB |
testcase_27 | AC | 29 ms
32,536 KB |
testcase_28 | AC | 29 ms
32,612 KB |
testcase_29 | AC | 14 ms
19,456 KB |
testcase_30 | AC | 4 ms
10,644 KB |
testcase_31 | AC | 3 ms
10,076 KB |
testcase_32 | AC | 4 ms
10,028 KB |
testcase_33 | AC | 4 ms
10,024 KB |
testcase_34 | AC | 4 ms
10,052 KB |
testcase_35 | AC | 4 ms
10,172 KB |
testcase_36 | AC | 4 ms
10,116 KB |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | AC | 4 ms
10,068 KB |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | AC | 5 ms
10,412 KB |
testcase_44 | AC | 19 ms
21,488 KB |
testcase_45 | WA | - |
testcase_46 | AC | 14 ms
17,272 KB |
testcase_47 | WA | - |
testcase_48 | AC | 39 ms
28,180 KB |
testcase_49 | AC | 23 ms
21,768 KB |
testcase_50 | AC | 5 ms
10,600 KB |
testcase_51 | AC | 33 ms
26,048 KB |
testcase_52 | AC | 6 ms
12,888 KB |
testcase_53 | AC | 38 ms
28,080 KB |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | AC | 3 ms
10,032 KB |
testcase_57 | WA | - |
testcase_58 | AC | 3 ms
10,100 KB |
testcase_59 | WA | - |
testcase_60 | AC | 3 ms
10,184 KB |
testcase_61 | WA | - |
testcase_62 | AC | 3 ms
10,012 KB |
testcase_63 | AC | 3 ms
10,084 KB |
testcase_64 | WA | - |
testcase_65 | AC | 3 ms
10,036 KB |
testcase_66 | AC | 3 ms
10,076 KB |
testcase_67 | AC | 3 ms
10,104 KB |
testcase_68 | WA | - |
testcase_69 | AC | 59 ms
35,032 KB |
testcase_70 | AC | 69 ms
37,160 KB |
testcase_71 | AC | 71 ms
37,112 KB |
testcase_72 | AC | 19 ms
21,680 KB |
testcase_73 | AC | 29 ms
26,128 KB |
testcase_74 | AC | 56 ms
37,200 KB |
testcase_75 | AC | 39 ms
37,208 KB |
testcase_76 | WA | - |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | AC | 13 ms
12,932 KB |
testcase_80 | WA | - |
testcase_81 | AC | 12 ms
12,836 KB |
testcase_82 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #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 ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- int N,M,K; int S,T; int X[202020],Y[202020]; vector<int> E[202020]; double D[2020]; vector<int> P[2020]; bitset<2020> B[2020]; double dist[2020][2020]; priority_queue<pair<double,int>> Q; pair<double,vector<int>> hoge(int start,unordered_set<int>& NG,vector<int> pref,double prel) { int i; FOR(i,N) D[i]=1e9, P[i].clear(), B[i].reset(); FORR(p,pref) D[p]=-1; D[start]=prel; B[start][start]=1; P[start]=pref; P[start].push_back(start); Q.push({-prel,start}); while(Q.size()) { double co=-Q.top().first; int cur=Q.top().second; Q.pop(); if(D[cur]!=co) continue; FORR(e,E[cur]) { if(NG.count(e*3000+cur)) continue; if(B[cur][e]) continue; //if(count(ALL(P[cur]),e)) continue; double d=co+dist[cur][e]; if(D[e]>d) { D[e]=d; P[e]=P[cur]; P[e].push_back(e); B[e]=B[cur]; B[e][e]=1; Q.push({-d,e}); } } } return {D[T],P[T]}; } void solve() { int i,j,k,l,r,x,y; string s; cin>>N>>M>>K>>S>>T; S--,T--; FOR(i,N) cin>>X[i]>>Y[i]; FOR(x,N) FOR(y,N) dist[x][y]=hypot(X[x]-X[y],Y[x]-Y[y]); FOR(i,M) { cin>>x>>y; E[x-1].push_back(y-1); E[y-1].push_back(x-1); } vector<pair<double,vector<int>>> ret; vector<pair<double,vector<int>>> cand; unordered_set<int> NG; ret.push_back(hoge(S,NG,vector<int>(),0)); while(ret.size()<K) { double sum=0; vector<int> pre; FOR(x,ret.back().second.size()-1) { if(x) { pre.push_back(ret.back().second[x-1]); sum+=dist[ret.back().second[x-1]][ret.back().second[x]]; } NG.clear(); FOR(i,ret.size()) { if(ret[i].second.size()<x+2) continue; FOR(y,x+1) if(ret[i].second[y]!=ret.back().second[y]) break; if(y!=x+1) continue; NG.insert(3000*ret[i].second[x]+ret[i].second[x+1]); NG.insert(3000*ret[i].second[x+1]+ret[i].second[x]); } cand.push_back(hoge(ret.back().second[x],NG,pre,sum)); } sort(ALL(cand)); while(cand.size()) { int ng=0; FORR(r,ret) if(r.second==cand[0].second) { break; ng=1; } if(ng==0) break; cand.erase(cand.begin()); } if(cand.empty()) break; if(cand[0].first>1e8) break; ret.push_back(cand[0]); cand.erase(cand.begin()); } FOR(i,K) { if(i<ret.size()) { _P("%.12lf\n",ret[i].first); } else { _P("-1\n"); } } } 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; }