Exemplo n.º 1
0
        static void Main(string[] args)
        {
            using (var io = new ContestIO("input.txt"))
            {
                var t = io.Read();
                io.ReadTrailNewLine();
                for (var i = 0; i < t; i++)
                {
                    var n = io.Read();
                    io.ReadTrailNewLine();

                    Dictionary <string, int> hash = new Dictionary <string, int>();
                    int idx   = 0;
                    var lines = new List <int[]>();

                    for (var j = 0; j < n; j++)
                    {
                        var line = io.ReadLine().Split(' ').Select(s =>
                        {
                            if (hash.ContainsKey(s))
                            {
                                return(hash[s]);
                            }
                            hash.Add(s, idx);
                            return(idx++);
                        }).ToArray();
                        lines.Add(line);
                    }
                    Solve(io, i + 1, lines, hash, idx);
                }
            }
        }
Exemplo n.º 2
0
        static void Solve(ContestIO io, int caseId, List <int[]> lines, Dictionary <string, int> hash, int wordsCount)
        {
            int[] en = new int[wordsCount];
            int[] fr = new int[wordsCount];
            Line(lines[0], en);
            Line(lines[1], fr);
            int result = int.MaxValue;

            SolveRec(lines, en, fr, 2, (r, f) => {
                if (f)
                {
                    if (r < result)
                    {
                        result = r;
                        return(true);
                    }
                }
                return(r < result);
            });
            io.WriteLine(string.Format("Case #{0}: {1}", caseId, result));
        }