46432023-03-30 13:59:57vááááTestnevelés óracsharpWrong answer 0/501.093s139328 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace tesi
{
    class Program
    {
        static List<int>[] b;
        static List<int> c = new List<int>();
        static int d = 0;
        static List<int>[] f = new List<int>[100000];
        static bool eloszor = true;
        static void add(int j)
        {

            d++;
            for (int i = 0; i < b[j].Count; i++)
            {
                if (c.Count() != 0)
                {
                    f[d] = new List<int>();
                    f[d + 1] = new List<int>();
                    f[d].AddRange(c);
                    c.Clear();
                }
                add(b[j][i]);
            }
            if (eloszor)
            {
                f[d] = new List<int>();
                if (d != 0)
                {
                    c.AddRange(f[d]);
                    d--;
                }
            }
            b[j].AddRange(c);
            c.Add(j);
        }
        static void Main(string[] args)
        {
            string[] a = Console.ReadLine().Split();
            int n = int.Parse(a[0])+1, k = int.Parse(a[1]);
            b = new List<int>[n];
            for (int i = 1; i < n; i++)
            {
                b[i] = new List<int>();
            }
            for (int i = 0; i < k; i++)
            {
                a = Console.ReadLine().Split();
                b[int.Parse(a[0])].Add(int.Parse(a[1]));
            }
            for (int i = 1; i < n; i++)
            {
                c.Clear();
                add(i);
            }
            for (int i = 1; i < n; i++)
            {
                c.Clear();
                 c.AddRange(b[i].Distinct().ToList());
                b[i].Clear();
                b[i].AddRange(c);
                b[i].Sort();
                b[i].Add(1);
            }
            int id = -1;
            string ki = "";
            int m = int.MinValue;
            for (int i = 1; i < n; i++)
            {
                m = -1;
                for (int j = 1; j < n; j++)
                {
                    if(m < b[j].Count)
                    {
                        id = j;
                        m = b[j].Count;
                    }
                }
                ki += id + " ";
                b[id].Clear();
            }
            Console.WriteLine(ki);
            Console.ReadKey();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/037ms23460 KiB
2Wrong answer0/035ms24024 KiB
3Time limit exceeded0/01.057s19888 KiB
4Wrong answer0/237ms24832 KiB
5Wrong answer0/335ms24660 KiB
6Wrong answer0/335ms25292 KiB
7Wrong answer0/334ms25340 KiB
8Runtime error0/1229ms75208 KiB
9Wrong answer0/339ms27192 KiB
10Time limit exceeded0/31.06s12332 KiB
11Time limit exceeded0/31.07s12104 KiB
12Runtime error0/193ms139328 KiB
13Time limit exceeded0/21.059s12348 KiB
14Time limit exceeded0/31.059s12664 KiB
15Time limit exceeded0/11.062s19312 KiB
16Time limit exceeded0/31.06s49296 KiB
17Time limit exceeded0/51.085s36492 KiB
18Time limit exceeded0/11.093s32776 KiB
19Time limit exceeded0/21.065s20608 KiB
20Runtime error0/3449ms137520 KiB
21Runtime error0/4549ms95900 KiB
22Runtime error0/4416ms137012 KiB