7666 2024. 01. 10 11:14:12 ananász Táblajáték csharp Elfogadva 50/50 35ms 24960 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace tabla
{
    class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());
            string[] lepesek = Console.ReadLine().Split();
            List<int> sorozat = new List<int>();
            sorozat.Add(0);
            for (int i = 0; i < K; i++)
            {
                if (lepesek[i] == "0")
                {
                    sorozat.Add(0);
                }
                else if (lepesek[i] == "1")
                {
                    sorozat.Add(1);
                }
                else if (lepesek[i] == "2")
                {
                    sorozat.RemoveAt(sorozat.Count - 1);
                }
                else if (lepesek[i] == "3")
                {
                    if (sorozat[sorozat.Count - 1] == 1)
                    {
                        sorozat[sorozat.Count - 1] = 0;
                    }
                    else
                    {
                        int id = sorozat.Count - 1;
                        while (!(sorozat[id] == 0 && sorozat[id - 1] == 1))
                        {
                            id--;
                        }
                        sorozat[id - 1] = 0;
                        while (id < sorozat.Count)
                        {
                            sorozat[id] = 1;
                            id++;
                        }
                    }
                }
                else if (lepesek[i] == "4")
                {
                    if (sorozat[sorozat.Count - 1] == 0)
                    {
                        sorozat[sorozat.Count - 1] = 1;
                    }
                    else
                    {
                        int id = sorozat.Count - 1;
                        while (!(sorozat[id] == 1 && sorozat[id - 1] == 0))
                        {
                            id--;
                        }
                        sorozat[id - 1] = 1;
                        while (id < sorozat.Count)
                        {
                            sorozat[id] = 0;
                            id++;
                        }
                    }
                }
            }
            Console.WriteLine(sorozat.Count - 1);
            int cv = 0;
            while (cv < sorozat.Count && sorozat[cv] == 0)
            {
                cv++;
            }
            if (sorozat.Count - cv == 0)
            {
                Console.WriteLine(0);
            }
            else
            {
                for (int i = cv; i < sorozat.Count; i++)
                {
                    Console.Write(sorozat[i]);
                }
                Console.WriteLine();
            }
            Console.ReadKey();
        }
    }
}
Részfeladat Összpont Teszt Verdikt Idő Memória
base 50/50
1 Elfogadva 0/0 30ms 20672 KiB
2 Elfogadva 0/0 28ms 21512 KiB
3 Elfogadva 3/3 28ms 21600 KiB
4 Elfogadva 3/3 29ms 21672 KiB
5 Elfogadva 3/3 28ms 22196 KiB
6 Elfogadva 3/3 29ms 22784 KiB
7 Elfogadva 3/3 28ms 22924 KiB
8 Elfogadva 3/3 30ms 22840 KiB
9 Elfogadva 3/3 29ms 23404 KiB
10 Elfogadva 3/3 35ms 24320 KiB
11 Elfogadva 3/3 28ms 24392 KiB
12 Elfogadva 3/3 35ms 24744 KiB
13 Elfogadva 4/4 29ms 24260 KiB
14 Elfogadva 4/4 34ms 24960 KiB
15 Elfogadva 4/4 28ms 24316 KiB
16 Elfogadva 4/4 35ms 24724 KiB
17 Elfogadva 4/4 29ms 24676 KiB