34162023-02-27 13:39:07AGergoTáblajátékcsharpAccepted 50/5035ms24780 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;
            

            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';
                            list.Insert(0, '0');
                            break;
                        }
                        else
                        {
                            list[i] = '0';
                        }
                    }
                }
            }


            while (list[0] == '0' && list.Count != 1)
            {
                list.RemoveAt(0);
            }

            Console.WriteLine(sor);

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

            //Console.ReadKey();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/028ms20816 KiB
2Accepted0/029ms21336 KiB
3Accepted3/328ms21724 KiB
4Accepted3/329ms22168 KiB
5Accepted3/328ms22536 KiB
6Accepted3/329ms23080 KiB
7Accepted3/328ms22860 KiB
8Accepted3/328ms23056 KiB
9Accepted3/328ms23268 KiB
10Accepted3/335ms24232 KiB
11Accepted3/328ms24004 KiB
12Accepted3/332ms24412 KiB
13Accepted4/429ms23780 KiB
14Accepted4/434ms24744 KiB
15Accepted4/428ms24208 KiB
16Accepted4/435ms24780 KiB
17Accepted4/428ms23716 KiB