fork(8) download
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.IO;
  6.  
  7. class Myon
  8. {
  9. public Myon() { }
  10. public static int Main()
  11. {
  12. new Myon().calc();
  13. return 0;
  14. }
  15.  
  16. int T = 10;
  17.  
  18.  
  19.  
  20. void calc()
  21. {
  22.  
  23. Random r = new Random(0);
  24. List<int> l = new List<int>();
  25.  
  26. l.Add(0);
  27. l.Add(417143);
  28. l.Add(727830);
  29. l.Add(108017);
  30. l.Add(577981);
  31. l.Add(673666);
  32. l.Add(510641);
  33. l.Add(306076);
  34. l.Add(38994);
  35. l.Add(834644);
  36.  
  37. Console.WriteLine("first 10 question");
  38. foreach (var item in l)
  39. {
  40. for (int j = 0; j < 10; j++)
  41. {
  42. Console.Write((((item >> (j * 2)) & 3) + 1) + " ");
  43. }
  44. Console.WriteLine();
  45. }
  46.  
  47. check(l);
  48. }
  49.  
  50. void check(List<int> l)
  51. {
  52. Dictionary<long, List<int>> dic = new Dictionary<long, List<int>>();
  53. for (int i = 0; i < (1 << 20); i++)
  54. {
  55. long p = 0;
  56. foreach (var item in l)
  57. {
  58. int count = 0;
  59. for (int j = 0; j < 10; j++)
  60. {
  61. if (((item >> (j * 2)) & 3) == ((i >> (j * 2)) & 3)) count++;
  62. }
  63. p <<= 4;
  64. p += count;
  65. }
  66. if (!dic.ContainsKey(p)) dic[p] = new List<int>();
  67. dic[p].Add(i);
  68. }
  69.  
  70. Random r = new Random();
  71. int max = 0;
  72. foreach (var item in dic)
  73. {
  74. if (item.Value.Count <= 1) continue;
  75. bool ok = false;
  76. for (int i = 1; i < 100 && !ok; i++)
  77. {
  78.  
  79. for (int j = 0; j < 1000; j++)
  80. {
  81. List<int> l2 = new List<int>();
  82. for (int k = 0; k < i; k++)
  83. {
  84. l2.Add(r.Next(0, 1 << 20));
  85. }
  86.  
  87. if (check2(l2, item.Value))
  88. {
  89. //具体例が欲しいときはここのコメントを外してね!
  90. /*
  91.   Console.Write("when answer is ");
  92.   for (int k = 0; k < 10; k++)
  93.   {
  94.   Console.Write(((int)(item.Key >> (2 * k)) & 3) + 1 + " ");
  95.   }
  96.   Console.WriteLine(" ({0} cases)", item.Value.Count);
  97.   foreach (var item2 in l2)
  98.   {
  99.   for (int k = 0; k < 10; k++)
  100.   {
  101.   Console.Write((((item2 >> (k * 2)) & 3) + 1) + " ");
  102.   }
  103.   Console.WriteLine();
  104.   }
  105.   */
  106.  
  107. max = Math.Max(i, max);
  108. ok = true;
  109. break;
  110. }
  111. }
  112. }
  113. }
  114.  
  115. Console.WriteLine("end");
  116. Console.WriteLine("question length : " + (10 + max));
  117. return;
  118. }
  119.  
  120.  
  121. bool check2(List<int> l, List<int> nums)
  122. {
  123. Dictionary<ulong, int> dic = new Dictionary<ulong, int>();
  124. foreach (var i in nums)
  125. {
  126. ulong p = 0;
  127. foreach (var item in l)
  128. {
  129. int count = 0;
  130. for (int j = 0; j < 10; j++)
  131. {
  132. if (((item >> (j * 2)) & 3) == ((i >> (j * 2)) & 3)) count++;
  133. }
  134. p <<= 4;
  135. p += (ulong)count;
  136. }
  137. if (dic.ContainsKey(p)) return false;
  138. else dic[p] = 1;
  139. }
  140. return true;
  141. }
  142. }
  143.  
  144.  
Success #stdin #stdout 2.22s 165568KB
stdin
Standard input is empty
stdout
first 10 question
1 1 1 1 1 1 1 1 1 1 
4 2 4 2 2 4 2 2 3 2 
3 2 2 1 4 3 2 1 4 3 
2 1 4 4 2 2 3 3 2 1 
2 4 4 3 2 1 2 4 1 3 
3 1 1 3 4 2 1 2 3 3 
2 1 4 3 3 3 1 4 4 2 
1 4 2 3 4 3 3 3 1 2 
3 1 2 2 1 3 2 3 1 1 
1 2 2 2 1 4 4 3 1 4 
end
question length : 11