76152024-01-10 09:08:33TortelliniJrA lehető legkevesebb átszállás (50 pont)csharpRuntime error 28/50185ms77196 KiB
using System;
using System.Collections.Generic;
using System.Linq;

namespace LegkAtsz
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inp = Console.ReadLine().Split().Select(int.Parse).ToArray();
            List<int>[] allelerh = new List<int>[inp[1] + 1];
            int[,] vonk = new int[inp[0] + 1, 2];
            int von = inp[0];
            int all = inp[1];
            bool bullshit = false;
            for (int i = 1; i <= all; i++)
            {
                allelerh[i] = new List<int>();
            }
            for (int i = 1; i <= von; i++)
            {
                inp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int u = inp[0]; u <= inp[1]; u++)
                {
                    allelerh[u].Add(i);
                }
                vonk[i, 0] = inp[0];
                vonk[i, 1] = inp[1];
            }
            int jel = 1;
            int locmax = 0;
            int locmaxn = 0;
            List<int> sol = new List<int>();
            while (jel != all)
            {
                for (int i = 0; i < allelerh[jel].Count; i++)
                {
                    if (vonk[allelerh[jel][i], 1] > locmax)
                    {
                        locmax = vonk[allelerh[jel][i], 1];
                        locmaxn = allelerh[jel][i];
                    }
                }
                if (allelerh[jel].Count == 0)
                {
                    bullshit = true;
                }
                jel = locmax;
                locmax = 0;
                sol.Add(locmaxn);
            }
            Console.WriteLine(sol.Count - 1);
            if (!bullshit)
            {
                foreach (var item in sol)
                {
                    Console.Write(item + " ");
                }
            }
            Console.ReadLine();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base28/50
1Accepted0/034ms22188 KiB
2Accepted0/0165ms73844 KiB
3Runtime error0/1185ms77196 KiB
4Runtime error0/1155ms76760 KiB
5Accepted2/232ms23944 KiB
6Accepted2/235ms24316 KiB
7Accepted2/248ms36740 KiB
8Accepted2/248ms37088 KiB
9Accepted2/254ms37172 KiB
10Accepted2/263ms41964 KiB
11Accepted2/279ms50860 KiB
12Accepted2/293ms55220 KiB
13Accepted2/248ms38984 KiB
14Accepted2/263ms44556 KiB
15Accepted2/279ms48336 KiB
16Accepted2/292ms55564 KiB
17Accepted2/2127ms68312 KiB
18Accepted2/2133ms68972 KiB
19Runtime error0/2140ms73320 KiB
20Runtime error0/2137ms73372 KiB
21Runtime error0/2136ms73336 KiB
22Runtime error0/2131ms73152 KiB
23Runtime error0/2104ms73276 KiB
24Runtime error0/2107ms73236 KiB
25Runtime error0/2108ms73096 KiB
26Runtime error0/2103ms73084 KiB
27Runtime error0/2104ms73140 KiB
28Runtime error0/2104ms73152 KiB