36432023-03-01 14:43:15vááááTáblajátékcsharpWrong answer 34/50108ms32840 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/028ms20784 KiB
2Wrong answer0/029ms21584 KiB
3Accepted3/328ms21624 KiB
4Accepted3/328ms21820 KiB
5Accepted3/329ms22148 KiB
6Accepted3/332ms22692 KiB
7Accepted3/328ms22080 KiB
8Accepted3/330ms22956 KiB
9Accepted3/328ms22524 KiB
10Partially correct1/3108ms31680 KiB
11Accepted3/328ms23052 KiB
12Partially correct1/348ms27344 KiB
13Partially correct1/428ms23088 KiB
14Partially correct1/448ms27748 KiB
15Partially correct1/432ms23992 KiB
16Partially correct1/4103ms32840 KiB
17Accepted4/432ms24776 KiB