1. 程式人生 > >2018 ACM-ICPC World Finals - Beijing

2018 ACM-ICPC World Finals - Beijing

comm its island final UNC https con == print

A.Catch the Plane

按時間倒著dp

技術分享圖片
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 typedef long long LL;
 4 typedef pair<LL, LL> pii;
 5 const int maxn = 2e6 + 10;
 6 int u[maxn], v[maxn];
 7 LL st[maxn], ed[maxn];
 8 double p[maxn];
 9 vector<pii> vec;
10 map<LL, double> f[maxn];
11 map<LL, double> :: iterator it; 12 vector<int> G[maxn]; 13 14 int main(){ 15 int m, n; 16 LL k; 17 scanf("%d %d %lld", &m, &n, &k); 18 for(int i = 1; i <= m; ++i){ 19 scanf("%d %d %lld %lld %lf", u + i, v + i, st + i, ed + i, p + i); 20 if
(u[i] == 1 || ed[i] > k) {m--; i--; continue;} 21 vec.push_back(pii(st[i], u[i])); 22 vec.push_back(pii(ed[i], v[i])); 23 } 24 vec.push_back(pii(k + 1, 1)); 25 sort(vec.begin(), vec.end()); 26 vec.erase(unique(vec.begin(), vec.end()), vec.end()); 27 for(int i = 1
; i <= m; ++i){ 28 int x = lower_bound(vec.begin(), vec.end(), pii(st[i], u[i])) - vec.begin(); 29 G[x].push_back(i); 30 } 31 for(int i = vec.size() - 1; i >= 0; i--){ 32 int x = vec[i].second; 33 LL now = vec[i].first; 34 double pre = x == 1 ? 1 : 0; 35 if(x != 1){ 36 it = f[x].upper_bound(now); 37 if(it != f[x].end()) pre = (*it).second; 38 } 39 double M = pre; 40 for(int j = 0; j < G[i].size(); ++j){ 41 int y = G[i][j]; 42 it = f[v[y]].upper_bound(ed[y]); 43 if(it == f[v[y]].end()) continue; 44 M = max(M, p[y] * (*it).second + (1 - p[y]) * pre); 45 } 46 f[x][now] = M; 47 } 48 it = f[0].begin(); 49 printf("%.10f\n", (*it).second); 50 return 0; 51 }
Aguin

B.Comma Sprinkler

C.Conquer The World

D.Gem Island

E.Getting a Jump on Crime

F.Go with the Flow

G.Panda Preserve

H.Single Cut of Failure

I.Triangles

J.Uncrossed Knight‘s Tour

K.Wireless is the New Fiber

2018 ACM-ICPC World Finals - Beijing