Beispiel #1
0
        static void Main(string[] args)
        {
            // var exStdIn = new System.IO.StreamReader("stdin.txt");
            // Console.SetIn(exStdIn);

            int nodeNum = int.Parse(Console.ReadLine());
            int edgeNum = int.Parse(Console.ReadLine());

            Carpenter carpenter = new Carpenter(nodeNum);

            for (int n = 0; n < edgeNum; n++)
            {
                int[] inputs   = Array.ConvertAll <string, int>(Console.ReadLine().Trim().Split(','), int.Parse);
                int   a        = inputs[0] - 1;
                int   b        = inputs[1] - 1;
                int   costAtoB = inputs[2];
                int   costBtoA = inputs[3];

                carpenter.tawnNodes[a].edges.Add(carpenter.tawnNodes[b], costAtoB);
                carpenter.tawnNodes[b].edges.Add(carpenter.tawnNodes[a], costBtoA);
            }

            int[] lastInputs = Array.ConvertAll <string, int>(Console.ReadLine().Trim().Split(','), int.Parse);
            int   start      = lastInputs[0] - 1;
            int   goal       = lastInputs[1] - 1;
            int   total      = lastInputs[2];
            int   price      = lastInputs[3];

            string output = carpenter.GetRewards(nodeNum, start, goal, total, price).ToString();

            Console.WriteLine(output);
            Console.ReadLine();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var exStdIn = new System.IO.StreamReader("stdin.txt");

            Console.SetIn(exStdIn);

            int tawnNum = int.Parse(Console.ReadLine());
            int pathNum = int.Parse(Console.ReadLine());

            Carpenter carpenter = new Carpenter(tawnNum);

            for (int n = 0; n < pathNum; n++)
            {
                int[] inputs   = Array.ConvertAll <string, int>(Console.ReadLine().Trim().Split(','), int.Parse);
                int   tawnIdA  = inputs[0] - 1;
                int   tawnIdB  = inputs[1] - 1;
                int   costAtoB = inputs[2];
                int   costBtoA = inputs[3];

                carpenter.tawnMaps[tawnIdA].trafficCosts.Add(carpenter.tawnMaps[tawnIdB], costAtoB);
                carpenter.tawnMaps[tawnIdB].trafficCosts.Add(carpenter.tawnMaps[tawnIdA], costBtoA);
            }

            int[] lastInputs  = Array.ConvertAll <string, int>(Console.ReadLine().Trim().Split(','), int.Parse);
            int   startTawnId = lastInputs[0] - 1;
            int   goalTawnId  = lastInputs[1] - 1;
            int   totalBudget = lastInputs[2];
            int   polePrice   = lastInputs[3];

            string output = carpenter.GetRewards(startTawnId, goalTawnId, totalBudget, polePrice).ToString();

            Console.WriteLine(output);
            Console.ReadLine();
        }