using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class Myon
{
public Myon() { }
public static int Main()
{
new Myon().calc();
return 0;
}
int T = 10;
void calc()
{
Random r = new Random(0);
List<int> l = new List<int>();
l.Add(0);
l.Add(417143);
l.Add(727830);
l.Add(108017);
l.Add(577981);
l.Add(673666);
l.Add(510641);
l.Add(306076);
l.Add(38994);
l.Add(834644);
Console.WriteLine("first 10 question");
foreach (var item in l)
{
for (int j = 0; j < 10; j++)
{
Console.Write((((item >> (j * 2)) & 3) + 1) + " ");
}
Console.WriteLine();
}
check(l);
}
void check(List<int> l)
{
Dictionary<long, List<int>> dic = new Dictionary<long, List<int>>();
for (int i = 0; i < (1 << 20); i++)
{
long p = 0;
foreach (var item in l)
{
int count = 0;
for (int j = 0; j < 10; j++)
{
if (((item >> (j * 2)) & 3) == ((i >> (j * 2)) & 3)) count++;
}
p <<= 4;
p += count;
}
if (!dic.ContainsKey(p)) dic[p] = new List<int>();
dic[p].Add(i);
}
Random r = new Random();
int max = 0;
foreach (var item in dic)
{
if (item.Value.Count <= 1) continue;
bool ok = false;
for (int i = 1; i < 100 && !ok; i++)
{
for (int j = 0; j < 1000; j++)
{
List<int> l2 = new List<int>();
for (int k = 0; k < i; k++)
{
l2.Add(r.Next(0, 1 << 20));
}
if (check2(l2, item.Value))
{
//具体例が欲しいときはここのコメントを外してね!
/*
Console.Write("when answer is ");
for (int k = 0; k < 10; k++)
{
Console.Write(((int)(item.Key >> (2 * k)) & 3) + 1 + " ");
}
Console.WriteLine(" ({0} cases)", item.Value.Count);
foreach (var item2 in l2)
{
for (int k = 0; k < 10; k++)
{
Console.Write((((item2 >> (k * 2)) & 3) + 1) + " ");
}
Console.WriteLine();
}
*/
max = Math.Max(i, max);
ok = true;
break;
}
}
}
}
Console.WriteLine("end");
Console.WriteLine("question length : " + (10 + max));
return;
}
bool check2(List<int> l, List<int> nums)
{
Dictionary<ulong, int> dic = new Dictionary<ulong, int>();
foreach (var i in nums)
{
ulong p = 0;
foreach (var item in l)
{
int count = 0;
for (int j = 0; j < 10; j++)
{
if (((item >> (j * 2)) & 3) == ((i >> (j * 2)) & 3)) count++;
}
p <<= 4;
p += (ulong)count;
}
if (dic.ContainsKey(p)) return false;
else dic[p] = 1;
}
return true;
}
}