fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4. #define double long double
  5.  
  6.  
  7. signed main() {
  8. ios_base::sync_with_stdio(false);
  9. cin.tie(NULL);
  10. cout.tie(NULL);
  11. freopen("ts3_input.txt", "r", stdin);
  12. //freopen("output.txt", "w", stdout);
  13.  
  14.  
  15. int T;
  16. double X;
  17. cin>>T;
  18. cin>>X;
  19. double totalsum=0;
  20. for(int te=1;te<=T;te++)
  21. {
  22.  
  23.  
  24. double W,E;
  25. cin>>W>>E;
  26. string ans="";
  27. pair<double,int> dp[62][62][62];
  28.  
  29.  
  30. dp[1][0][0]={W/3+E/3,0};
  31. dp[0][1][0]={W/3+E/3,1};
  32. dp[0][0][1]={W/3+E/3,2};
  33. dp[1][1][0]={W/3+W+E/3,0};
  34. dp[0][1][1]={W/3+W+E/3,1};
  35. dp[1][0][1]={W/3+W+E/3,2};
  36.  
  37.  
  38.  
  39. for(int r=1;r<62;r++)
  40. {
  41. for(int p=1;p<62;p++)
  42. {
  43. for(int s=1;s<62;s++)
  44. {
  45. vector<double> v={dp[r-1][p][s].first+(W*p)/(r+p+s-1)+(E*s)/(r+p+s-1),
  46. dp[r][p-1][s].first+(W*s)/(r+p+s-1)+(E*r)/(r+p+s-1),
  47. dp[r][p][s-1].first+(W*r)/(r+p+s-1)+(E*p)/(r+p+s-1)};
  48.  
  49. //if(dp[r-1][p][s].first==-1.0 || dp[r][p-1][s].first==-1.0 || dp[r][p][s-1].first==-1.0)
  50. // cout<<"fuck"<<endl;
  51.  
  52. dp[r][p][s].first=*max_element(v.begin(), v.end());
  53. dp[r][p][s].second=distance(v.begin(),max_element(v.begin(), v.end()));
  54. }
  55. }
  56. }
  57. double maxi=0;
  58. vector<int> indices={0,0,0};
  59. for(int r=0;r<62;r++)
  60. {
  61. for(int p=0;p<62;p++)
  62. {
  63. for(int s=0;s<62;s++)
  64. {
  65. if(r+p+s==61 & dp[r][p][s].first>maxi)
  66. {
  67. maxi= dp[r][p][s].first;
  68. indices[0]=r;
  69. indices[1]=p;
  70. indices[2]=s;
  71. if(dp[indices[0]][indices[1]][indices[2]].second==0) indices[0]--;
  72.  
  73. else if(dp[indices[0]][indices[1]][indices[2]].second==1) indices[1]--;
  74.  
  75. else indices[2]--;
  76.  
  77. }
  78. }
  79. }
  80. }
  81. totalsum+=maxi;
  82. //cout<<maxi<<endl;
  83. for(int i=0;i<60;i++)
  84. { //cout<<dp[indices[0]][indices[1]][indices[2]].first<<endl;
  85. //cout<<indices[0]<<" "<<indices[1]<<" "<<indices[2]<<endl;
  86. /*if((indices[0] && indices[1] && indices[2])==0)
  87.   {
  88.   cout<<indices[0]<<" "<<indices[1]<<" "<<indices[2]<<endl;
  89.   }*/
  90.  
  91. if(dp[indices[0]][indices[1]][indices[2]].second==2)
  92. {
  93. ans.push_back('S');
  94. indices[2]--;
  95. }
  96. else if(dp[indices[0]][indices[1]][indices[2]].second==1)
  97. {
  98. ans.push_back('P');
  99. indices[1]--;
  100. }
  101.  
  102. else if(dp[indices[0]][indices[1]][indices[2]].second==0)
  103. {
  104. ans.push_back('R');
  105. indices[0]--;
  106. }
  107.  
  108. }
  109.  
  110. reverse(ans.begin(),ans.end());
  111. //cout<<ans.size()<<endl;
  112. cout<<"Case #"<<te<<": "<<ans<<endl;
  113. }
  114. //cout<<(totalsum/200)<<" "<<X<<endl;
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123. return 0;
  124. }
  125.  
  126.  
  127.  
Success #stdin #stdout 0s 5644KB
stdin
Standard input is empty
stdout
Standard output is empty