Submission #3257718


Source Code Expand

using System.Collections.Generic;
using static System.Console;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = ReadLine().ToCharArray().Select(i => (int)i).ToArray();
            var t = ReadLine().ToCharArray().Select(i => (int)i).ToArray();

            var buffer = new List<int>();
            var l = s.Count();
            var result = true;

            for (int i = 0; i < l; i++)
            {
                if (s[i] == t[i])
                {
                    buffer.Add(s[i]);
                    continue;
                }
                else
                {
                    if (buffer.Contains(s[i]))
                    {
                        result = false;
                        break;
                    }
                    else
                    {
                        if (buffer.Contains(t[i]))
                        {
                            result = false;
                            break;
                        }


                        var asciiOfTargetChar = s[i];

                        for (int j = 0; j < l; j++)
                        {
                            if (s[j] == asciiOfTargetChar)
                            {
                                s[j] = t[i];
                            }
                            else
                            {
                                if (s[j] == t[i])
                                {
                                    s[j] = asciiOfTargetChar;
                                }
                            }
                        }

                        buffer.Add(t[i]);
                        continue;
                    }
                }
            }

            WriteLine(result ? "Yes" : "No");

        }
    }
}

Submission Info

Submission Time
Task C - String Transformation
User MayoToya
Language C# (Mono 4.6.2.0)
Score 300
Code Size 1922 Byte
Status AC
Exec Time 46 ms
Memory 20832 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 24
Set Name Test Cases
Sample sample_01, sample_02, sample_03
All 0_min0, 0_min1, 1_small0, 1_small1, 1_small2, 2_medium0, 2_medium1, 2_medium2, 2_medium3, 2_medium4, 3_max0, 3_max1, 3_max2, 3_max3, 3_max4, 3_max5, 3_max6, 3_max7, 3_max8, 3_max9, 5_hand0, sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
0_min0 AC 24 ms 13280 KiB
0_min1 AC 23 ms 9300 KiB
1_small0 AC 23 ms 11232 KiB
1_small1 AC 23 ms 11232 KiB
1_small2 AC 24 ms 13396 KiB
2_medium0 AC 34 ms 15584 KiB
2_medium1 AC 38 ms 18784 KiB
2_medium2 AC 27 ms 11488 KiB
2_medium3 AC 44 ms 19936 KiB
2_medium4 AC 39 ms 15584 KiB
3_max0 AC 37 ms 20832 KiB
3_max1 AC 45 ms 20704 KiB
3_max2 AC 42 ms 18784 KiB
3_max3 AC 46 ms 19936 KiB
3_max4 AC 42 ms 19040 KiB
3_max5 AC 35 ms 16736 KiB
3_max6 AC 39 ms 20704 KiB
3_max7 AC 38 ms 17888 KiB
3_max8 AC 39 ms 17888 KiB
3_max9 AC 39 ms 18528 KiB
5_hand0 AC 23 ms 11232 KiB
sample_01 AC 23 ms 9184 KiB
sample_02 AC 23 ms 11232 KiB
sample_03 AC 23 ms 11232 KiB