码迷,mamicode.com
首页 > 其他好文 > 详细

2018 ACM-ICPC World Finals - Beijing

时间:2018-04-19 16:08:24      阅读:1596      评论:0      收藏:0      [点我收藏+]

标签:color   acm-icpc   ase   hid   mes   comm   acm   failure   unique   

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

标签:color   acm-icpc   ase   hid   mes   comm   acm   failure   unique   

原文地址:https://www.cnblogs.com/Aguin/p/8883601.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!