34122023-02-27 13:28:49AGergoTáblajátékcsharpRuntime error 40/5034ms24912 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 lepesszam = int.Parse(Console.ReadLine());

            int sor = 0;
            //string hely = "0";

            List<char> list = new List<char>();
            list.Add('0');

            string[] be = Console.ReadLine().Split();

            foreach (var item in be)
            {
                if (item == "0")
                {
                    sor++;

                    list.Add('0');
                }
                else if (item == "1")
                {
                    sor++;

                    list.Add('1');

                } 
                else if (item == "2")
                {
                    sor--;

                    list.RemoveAt(list.Count-1);
                }    
                else if (item == "3")
                {
                    for (int i = list.Count-1; i >= 0; i--)
                    {
                        if (list[i] == '1')
                        {
                            list[i] = '0';
                            break;
                        }
                        else
                        {
                            list[i] = '1';
                        }
                    }
                }    
                else if (item == "4")
                {
                    for (int i = list.Count - 1; i >= 0; i--)
                    {
                        if (list[i] == '0')
                        {
                            list[i] = '1';
                            break;
                        }
                        else
                        {
                            list[i] = '0';
                        }
                    }
                }
            }


            while (list[0] == '0')
            {
                list.RemoveAt(0);
            }

            Console.WriteLine(sor);

            for (int i = 0; i < list.Count; i++)
            {
                Console.Write(list[i]);
            }

            //Console.ReadKey();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base40/50
1Accepted0/028ms20796 KiB
2Accepted0/028ms20904 KiB
3Runtime error0/330ms20764 KiB
4Accepted3/329ms21608 KiB
5Accepted3/328ms21776 KiB
6Accepted3/329ms22012 KiB
7Accepted3/328ms22284 KiB
8Accepted3/329ms22704 KiB
9Runtime error0/332ms22736 KiB
10Accepted3/332ms24156 KiB
11Accepted3/328ms23120 KiB
12Accepted3/334ms24436 KiB
13Accepted4/428ms23684 KiB
14Accepted4/434ms24580 KiB
15Accepted4/429ms23944 KiB
16Accepted4/434ms24912 KiB
17Runtime error0/432ms24364 KiB