Beispiel #1
0
 static int[] computeSpectre(n_Cube cube)
 {
     int[] spectre = new int[cube.n_cube.Length];
     for (var i = 1; i < cube.n_cube.Length; i++)
     {
         for (var j = 0; j < cube.n_cube[i].Length; j++)
         {
             var node = cube.n_cube[i][j];
             var pmin = node.linked.Min(n => n.m);
             node.p = pmin;
             if (node.p < i - 1)
             {
                 node.m = node.p;
             }
             else if (node.l)
             {
                 node.m = i - 1;
             }
             else
             {
                 node.m = i;
             }
             pmin       = node.m < pmin ? node.m : pmin;
             spectre[i] = spectre[i] < node.m ? node.m : spectre[i];
         }
     }
     return(spectre);
 }
Beispiel #2
0
        private static void SetMarks(n_Cube cube, string func)
        {
            var nodes = new List <Node>();

            for (var i = 0; i < func.Length; i++)
            {
                if (func[i] != '1')
                {
                    continue;
                }
                cube.MNodes[i].l = true;
                nodes.Add(cube.MNodes[i]);
            }
            cube.startNodes = nodes.ToArray();
        }
Beispiel #3
0
 public static void Solve(n_Cube cube)
 {
     int[][][] xorNodes = new int[cube.startNodes.Length][][];
     for (var i = 0; i < cube.startNodes.Length; i++)
     {
         xorNodes[i] = cube.startNodes
                       .Select(x => x.vector)
                       .Select(x => Xor(cube.startNodes[i].vector, x))
                       .ToArray();
     }
     int[][] spectres = new int[xorNodes.Length][];
     for (var i = 0; i < xorNodes.Length; i++)
     {
         repointCube(xorNodes[i], cube);
         spectres[i] = computeSpectre(cube);
     }
     Console.WriteLine(String.Join(",", computeMaxSpectre(spectres, cube.n_cube.Length)));
 }
Beispiel #4
0
        static void Main(string[] args)
        {
            var stopWatch = new Stopwatch();
            var lines     = File.ReadAllLines("in.txt");

            Console.WriteLine(lines[0].Length);
            Console.WriteLine(Math.Log(lines[0].Length, 2));
            stopWatch.Start();
            var cube = new n_Cube((int)Math.Log(lines[0].Length, 2));

            SetMarks(cube, lines[0]);
            Algoritm.Solve(cube);
            stopWatch.Stop();
            var ts          = stopWatch.Elapsed;
            var elapsedTime = $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}.{ts.Milliseconds / 10:00}";

            Console.WriteLine("RunTime " + elapsedTime);
        }
Beispiel #5
0
 static void repointCube(int[][] vectors, n_Cube cube) => cube.repoint(vectors);