Task: | Lemonade Trade |
Sender: | KnowYourArchitecture |
Submission time: | 2017-10-24 21:07:38 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.22 s | details |
#2 | ACCEPTED | 0.35 s | details |
#3 | ACCEPTED | 0.44 s | details |
#4 | ACCEPTED | 0.26 s | details |
#5 | ACCEPTED | 0.22 s | details |
#6 | ACCEPTED | 0.34 s | details |
#7 | ACCEPTED | 0.44 s | details |
#8 | ACCEPTED | 0.20 s | details |
#9 | ACCEPTED | 0.17 s | details |
#10 | ACCEPTED | 0.04 s | details |
#11 | ACCEPTED | 0.03 s | details |
Code
#include <bits/stdc++.h> #define F first #define S second using namespace std; typedef long long ll; /*struct MaxFlow{ vector<vector<ll>> f; vector<vector<int>>g; vector<int> used; int cc; ll flow(int x,int t,ll fl,ll miv){ if(x==t)return fl; üsed[c]=cc; for(int nx:g[x]){ if(used[nx]!=cc&&d[x][nx]>=miv){ ll r=flow(nx,t,min(fl,f[x][nx]),miv); if(r>0){ f[x][nx]-=r;f[nx][x]+=r; return r; } } } return 0; } ll getMaxFlow(int source,int sink,ll maxv){ cc=1; ll r=0; ll k=1; while(k*2<=maxv)k*=2; for(;k>0;k/=2){ while(ll t=dlow(source,sink,maxv,k)){ r+=t;cc++; } cc++ } return r; } void addEdge(int a,int b,ll c){ if(f[a][b]==0 && f[b][a]==0){ g[a].push_back(b); g[b].push_back(a); } f[a][b]+=c; } MaxFlow(int n) :f(n+1),g(n+1),used(n+1){ for(int i=1;i<=n;i++){ f[i]=vector<ll>(n+1); } } };*/ #define double long double map<string, double> c; int main() { int n; cin >> n; c["pink"] = 0; for(int i=0;i<n;i++) { string a,b;double l; cin>>b>>a>>l; l = log(l); if(!c.count(a))continue; if(c.count(b))c[b]=max(c[b],c[a]+l); else c[b]=c[a]+l; } if (c.count("blue")) cout<<setprecision(15)<<fixed<<min(max(exp(c["blue"]), (double)(0)), (double)(10.0))<<endl; else cout << "0.00000000000000000000" << endl; return 0; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
100000 blue pink 0.999999 pink blue 0.999999 blue pink 1.000001 pink blue 1.000001 ... |
correct output |
---|
1.0512700 |
user output |
---|
1.051270018824247 |
Test 2
Verdict: ACCEPTED
input |
---|
100000 c1 pink 1.99999 c2 c1 1.99999 c3 c2 1.99999 c4 c3 1.99999 ... |
correct output |
---|
0.999998749994228 |
user output |
---|
0.999998749994228 |
Test 3
Verdict: ACCEPTED
input |
---|
100000 c1 pink 0.5000025 c2 c1 0.5000025 c3 c2 0.5000025 c4 c3 0.5000025 ... |
correct output |
---|
0.999998749994231 |
user output |
---|
0.999998749994231 |
Test 4
Verdict: ACCEPTED
input |
---|
99858 0 pink 1.000000 0 0 1.000001 1 0 1.000001 2 0 1.000001 ... |
correct output |
---|
1.0006312 |
user output |
---|
1.000631198806681 |
Test 5
Verdict: ACCEPTED
input |
---|
99542 0 pink 1.000000 1 0 1.000001 2 0 1.000001 3 0 1.000001 ... |
correct output |
---|
1.0003150 |
user output |
---|
1.000315049460160 |
Test 6
Verdict: ACCEPTED
input |
---|
100000 c1 pink 1.999999 c2 c1 1.999999 c3 c2 1.999999 c4 c3 1.999999 ... |
correct output |
---|
10.000000000000000 |
user output |
---|
10.000000000000000 |
Test 7
Verdict: ACCEPTED
input |
---|
100000 1 pink 1.25 2 pink 1.25 3 1 0.8 3 2 0.7 ... |
correct output |
---|
1.000000 |
user output |
---|
1.000000000000000 |
Test 8
Verdict: ACCEPTED
input |
---|
99542 blue 315 1.000000 1 0 1.000001 2 0 1.000001 3 0 1.000001 ... |
correct output |
---|
0.000000 |
user output |
---|
0.00000000000000000000 |
Test 9
Verdict: ACCEPTED
input |
---|
99540 1 0 1.000001 2 0 1.000001 3 0 1.000001 4 0 1.000001 ... |
correct output |
---|
0.000000 |
user output |
---|
0.00000000000000000000 |
Test 10
Verdict: ACCEPTED
input |
---|
5 orange pink 1.9 yellow orange 1.9 green yellow 1.9 black green 1.9 ... |
correct output |
---|
6.646371000000000 |
user output |
---|
6.646371000000000 |
Test 11
Verdict: ACCEPTED
input |
---|
0 |
correct output |
---|
0.000000 |
user output |
---|
0.00000000000000000000 |