2018 ACM-ICPC World Finals - Beijing

Posted Algorithms Crush Me

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2018 ACM-ICPC World Finals - Beijing相关的知识,希望对你有一定的参考价值。

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的主要内容,如果未能解决你的问题,请参考以下文章

2018 ACM-ICPC World Finals Gym-102482C Conquer the World

2018 ACM-ICPC World Finals - Beijing

2018 ACM-ICPC World Finals Gym-102482I Triangles

2018-2019 ACM-ICPC, Asia East Continent Final L Eventual … Journey

2017-2018 ACM-ICPC Asia East Continent League Final L. SOS(博弈,思维)

2017-2018 ACM-ICPC Asia East Continent League Final J. Straight Master(差分+思维)