Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define sc(a) scanf("%d", &a)
  4. #define sc2(a, b) scanf("%d%d", &a, &b)
  5. #define sc3(a, b, c) scanf("%d%d%d", &a, &b, &c)
  6. #define scs(a) scanf("%s", a)
  7. #define pri(x) printf("%d\n", x)
  8. #define prie(x) printf("%d ", x)
  9. #define pris() printf("\n")
  10. #define fi first
  11. #define se second
  12. #define mp make_pair
  13. #define pb push_back
  14. #define BUFF ios::sync_with_stdio(false)
  15. #define db(x) cerr << #x << " == " << x << endl
  16. #define power(a,x) __gnu_cxx::power(a, x)
  17. #define eps 1e-5
  18. typedef long long int ll;
  19. typedef long double ld;
  20. typedef pair<int, int> ii;
  21. typedef vector<int> vi;
  22. typedef vector<vector<int> > vvi;
  23. typedef vector<ii> vii;
  24. const int INF = 0x3f3f3f3f;
  25. const ll LINF = 0x3f3f3f3f3f3f3f3fll;
  26. const ld pi = acos(-1);
  27. const int MOD = 1e9 + 7;
  28. map<string,double> dp;
  29. int main()
  30. {
  31.     BUFF;
  32.     int n;
  33.     cin>>n;
  34.     dp["pink"]=1;
  35.     while(n--)
  36.     {
  37.         string a,b;
  38.         cin>>a>>b;
  39.         double x;
  40.         cin>>x;
  41.         if(dp.count(a)){
  42.             double y = 0;
  43.             if(dp.count(b) ) y = log(dp[b]);
  44.             dp[a]=min(max(log2(dp[a]),log2(y)+log2(x)),(double)INF);
  45.         }else{
  46.             dp[a] = log2(x);
  47.         }
  48.     }
  49.     cout<<setprecision(15)<<fixed;
  50.     dp["blue"]=min((double)10,pow(dp["blue"], 2) );
  51.     cout<<dp["blue"]<<endl;
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement