36442023-03-01 14:43:15vááááTáblajátékcsharpWrong answer 34/50107ms32796 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace táblajáték
{
    class Program
    {
        static string minus(string bi)
        {
            string ki = "";
            int vált = -1;
            for (int i = bi.Length-1; i > 0; i--)
            {
                if(bi[i] == '0' && bi[i-1] == '1')
                {
                    vált = i;
                    break;
                }
            }
            if (vált == -1)
            {
                for (int i = 0; i < bi.Length - 1; i++)
                {
                    ki += bi[i];
                }
                ki += '0';
            }
            else
            {
                for (int i = 0; i < bi.Length; i++)
                {
                    if (i < vált - 1) ki += bi[i];
                    if (i == vált - 1) ki += '0';
                    if (i == vált) ki += '1';
                    if (i > vált) ki += bi[i];
                }
                if(ki[0] == '0')
                {
                    bi = "";
                    for (int i = 1; i < ki.Length; i++)
                    {
                        bi += '1';
                    }
                    ki = bi;
                }
            }
            return ki;
        }

        static string plus(string bi)
        {
            string ki = "";
            int vált = -1;
            for (int i = bi.Length - 1; i > 0; i--)
            {
                if (bi[i] == '1' && bi[i - 1] == '0')
                {
                    vált = i;
                    break;
                }
            }
            if(bi == "0")
            {
                ki = "1";
            }
            else if (bi[bi.Length-1] == '0')
            {
                for (int i = 0; i < bi.Length-1; i++)
                {
                    ki += bi[i];
                }
                ki += "1";
            }
            else {
                if (vált == -1)
                {
                    ki += '1';
                    for (int i = 0; i < bi.Length; i++)
                    {
                        ki += '0';
                    }
                }
                else
                {
                    for (int i = 0; i < bi.Length; i++)
                    {
                        if (i < vált - 1) ki += bi[i];
                        if (i == vált - 1) ki += '1';
                        if (i == vált) ki += '0';
                        if (i > vált) ki += '0';
                    }
                }
            }
            return ki;
        }
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int sor = 0;
            string t = Console.ReadLine();
            string[] a = new string[n];
            string bin = "0";
            for (int i = 0; i < n; i++)
            {
                a[i] = t.Split()[i];
            }
            string bintemp;
            for (int i = 0; i < n; i++)
            {
                if (a[i] == "0")
                {
                    sor++;
                    if(bin != "0") bin += "0";
                }
                if (a[i] == "1")
                {
                    sor++;
                    if (bin == "0") bin = "1";
                    else bin += "1";
                }
                if (a[i] == "2")
                {
                    sor--;
                    if(bin.Length == 1)
                    {
                        bin = "0";
                    }
                    else   bin = bin.Substring(0, bin.Length - 1);
                }
                if (a[i] == "3")
                {
                    bin = minus(bin);
                }
                if (a[i] == "4")
                {
                    bin = plus(bin);
                }
            }
            Console.WriteLine(sor);
            Console.WriteLine(bin);
            Console.ReadLine();
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base34/50
1Accepted0/028ms20600 KiB
2Wrong answer0/030ms21500 KiB
3Accepted3/328ms21376 KiB
4Accepted3/328ms22156 KiB
5Accepted3/328ms22028 KiB
6Accepted3/329ms23232 KiB
7Accepted3/327ms22752 KiB
8Accepted3/330ms23848 KiB
9Accepted3/328ms23180 KiB
10Partially correct1/3107ms32580 KiB
11Accepted3/328ms23896 KiB
12Partially correct1/346ms28544 KiB
13Partially correct1/428ms23872 KiB
14Partially correct1/445ms28504 KiB
15Partially correct1/430ms24300 KiB
16Partially correct1/4103ms32796 KiB
17Accepted4/432ms24304 KiB