fork download
  1. /*
  2. Vishal Raj
  3. Indian Institute of Technology Kharagpur
  4. */
  5. #include <bits/stdc++.h>
  6.  
  7. using namespace std;
  8.  
  9. #define vi vector<int>
  10. #define FOR(i,l,r) for( int i = l-(l>r); i != r-(l>r); i += 1-2*(l>r) )
  11. #define pb push_back
  12. #define all(X) (X).begin(),(X).end()
  13. #define xx first
  14. #define yy second
  15. #define ii pair<int,int>
  16. #define vii vector<ii>
  17.  
  18. int ans = 0;
  19. mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  20.  
  21. int Rand( int a, int b ) {
  22. return a + rng()%(b-a);
  23. }
  24.  
  25. void solve() {
  26. vi v(12,0);
  27. int qq = 0;
  28. vi qu(8,-1);
  29. vi se(4,-1);
  30. vi fi(2,-1);
  31. FOR(i,0,4) {
  32. int k = i*3;
  33. FOR(j,k,k+3) {
  34. int l = j+1;
  35. if( l == k+3 ) l = k;
  36. if( rng()%2 ) {
  37. v[l]++;
  38. } else {
  39. v[j]++;
  40. }
  41. }
  42. vii u(3,{0,0});
  43. FOR(j,0,3) u[j] = {v[k+j],k+j};
  44. sort(all(u));
  45. int out = 0;
  46. if( u[0].xx == u.back().xx ) {
  47. out = rng()%3;
  48. }
  49. FOR(j,0,3) {
  50. if( j != out ) {
  51. qu[qq++] = u[j].yy;
  52. }
  53. }
  54. }
  55. qq = 0;
  56. FOR(i,0,4) {
  57. int k = i*2;
  58. if( rng()%2 ) {
  59. v[qu[k+1]]++;
  60. se[qq++] = qu[k+1];
  61. } else {
  62. v[qu[k]]++;
  63. se[qq++] = qu[k];
  64. }
  65. }
  66. qq = 0;
  67. FOR(i,0,2) {
  68. int k = i*2;
  69. if( rng()%2 ) {
  70. fi[qq++] = se[k+1];
  71. v[se[k+1]]++;
  72. } else {
  73. fi[qq++] = se[k];
  74. v[se[k]]++;
  75. }
  76. }
  77. qq = 0;
  78. if( rng()%2 ) {
  79. v[fi[1]]++;
  80. ans += v[fi[1]];
  81. } else {
  82. v[fi[0]]++;
  83. ans += v[fi[0]];
  84. }
  85. }
  86.  
  87. int main() {
  88. int times; cin>>times;
  89. FOR(i,0,times) solve();
  90. cout<<ans*1.0/times*1.0<<"\n";
  91. return 0;
  92. }
Success #stdin #stdout 0.04s 4332KB
stdin
100000
stdout
4.37483