156872025-02-21 18:15:53Teret222Tükörtojás (75 pont)csharpRuntime error 0/7514ms3032 KiB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp11
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            bool[] start = ToBool(Console.ReadLine().ToCharArray());
            bool[] end = ToBool(Console.ReadLine().ToCharArray());
            bool[] temp = new bool[start.Length];
            start.CopyTo(temp, 0);
            int össz = 0;

            for (int i = N-1; i >= 0; i--)
            {
                if (temp[i] != end[i])
                {
                    temp = Flip(temp, i);
                    össz++;
                }
                
            }
            Console.WriteLine(össz);
        }
        static bool[] ToBool(char[] chars)
        {
            bool[] bools = new bool[chars.Length];

            for (int i = 0; i < chars.Length; i++)
            {
                if (chars[i] == 'S') bools[i] = true;
                else bools[i] = false;
            }

            return bools;
        }

        static bool[] Flip(bool[] bools, int n)
        {
            bool[] result = new bool[bools.Length];

            for (int i = 0; i < n; i++)
                result[i] = !bools[i];

            return result;
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base0/75
1Runtime error0/014ms2760 KiB
2Runtime error0/014ms2644 KiB
3Runtime error0/514ms2580 KiB
4Runtime error0/514ms2952 KiB
5Runtime error0/514ms2824 KiB
6Runtime error0/514ms2800 KiB
7Runtime error0/514ms2556 KiB
8Runtime error0/514ms2752 KiB
9Runtime error0/514ms2768 KiB
10Runtime error0/514ms2772 KiB
11Runtime error0/514ms2776 KiB
12Runtime error0/514ms2768 KiB
13Runtime error0/514ms3032 KiB
14Runtime error0/514ms2508 KiB
15Runtime error0/514ms2760 KiB
16Runtime error0/514ms2740 KiB
17Runtime error0/514ms2964 KiB