95592024-02-23 08:48:21Leventusz09Parti (75 pont)csharpWrong answer 60/75275ms42472 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Parti{
    class Program{
        static void Main(){
            int N = int.Parse(Console.ReadLine());
            int[][] matrix = new int[N][]; // soronkénti bemenetek
            int[] cp = new int[N]; //emberek hivatkozás száma
            bool[] n = new bool[N]; //nem meghívottak

            for(int i=0; i<N; i++){
                matrix[i] = Console.ReadLine().Split().Select(x => int.Parse(x) - 1).ToArray();
                cp[matrix[i][0]]++;
                cp[matrix[i][1]]++;
            }

            int o1 = N;

            bool t = false;
            while(!t){
                t = true;
                for(int i=0; i<N; i++){
                    if (cp[i] < 2 && !n[i]){
                        t = false;
                        n[i] = true;
                        o1--;
                        cp[matrix[i][0]]--;
                        cp[matrix[i][1]]--;
                    }
                }
            }
            Console.WriteLine(o1);
            for (int i = 0; i < N; i++) if (!n[i]) Console.Write((i + 1) + " ");
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base60/75
1Accepted0/032ms22216 KiB
2Accepted0/0177ms36200 KiB
3Accepted3/332ms23264 KiB
4Accepted3/332ms23788 KiB
5Wrong answer0/332ms24428 KiB
6Accepted3/332ms24764 KiB
7Accepted3/332ms25220 KiB
8Accepted4/434ms25540 KiB
9Accepted4/434ms25980 KiB
10Accepted4/435ms26236 KiB
11Accepted4/434ms26168 KiB
12Accepted4/437ms26428 KiB
13Accepted4/439ms27392 KiB
14Accepted4/443ms27852 KiB
15Accepted4/4168ms39628 KiB
16Accepted4/4194ms40708 KiB
17Accepted4/4245ms41292 KiB
18Accepted4/4261ms42128 KiB
19Runtime error0/4275ms42472 KiB
20Runtime error0/4203ms42380 KiB
21Runtime error0/4204ms42328 KiB
22Accepted4/430ms25928 KiB