Submission #50604225


Source Code Expand

using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml.Linq;

namespace ABC {
	class Program {
		static void Main(string[] args) {
			var solver = new Solver();
			solver.Solve();
		}
	}
	public class Solver {

		readonly int N;
		readonly string S;
		readonly int Q;
		readonly (char, char)[] Query;
		public Solver() : this(Console.In, Console.Out){
		}
		public Solver(TextReader reader, TextWriter wrighter) {
			Console.SetIn(reader);
			Console.SetOut(wrighter);

			N = int.Parse(reader.ReadLine());
			S = reader.ReadLine();
			Q = int.Parse(reader.ReadLine());

			Query = new (char,char)[Q];
			for( int i = 0; i < Query.Length; i++ ) {
				var a = Console.ReadLine().Split(' ').ToArray();
				Query[i] = (a[0][0], a[1][0]);
			}

		}


		public void Solve() {

			char[] map = new char[26];
            for ( int i = 0; i < map.Length; i++)
            {
				map[i] = (char)('a' + i);
            }
            foreach ( var v in Query ) {
                for (int i = 0; i < map.Length; i++) {
					if( map[i] == v.Item1 ) {
						map[i] = v.Item2;
					}
                }
            }
			char[] result = S.ToArray();
            for (int i = 0; i < map.Length; i++ ) {
                for (int j = 0; j < S.Length; j++)
                {
					if( S[j]== (char)('a' + i) ) {
						result[j] = map[i];
					}
                }
			}
			Console.WriteLine(new string(result));

		}
	}
}

Submission Info

Submission Time
Task C - Many Replacement
User susuki_zzz
Language C# 11.0 (.NET 7.0.7)
Score 350
Code Size 1604 Byte
Status AC
Exec Time 110 ms
Memory 56120 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 350 / 350
Status
AC × 3
AC × 29
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 44 ms 25860 KiB
00_sample_01.txt AC 48 ms 25696 KiB
00_sample_02.txt AC 41 ms 25624 KiB
01_random_03.txt AC 99 ms 56092 KiB
01_random_04.txt AC 102 ms 56120 KiB
01_random_05.txt AC 110 ms 55956 KiB
01_random_06.txt AC 106 ms 56060 KiB
01_random_07.txt AC 103 ms 56064 KiB
01_random_08.txt AC 70 ms 38104 KiB
01_random_09.txt AC 71 ms 32580 KiB
01_random_10.txt AC 83 ms 42092 KiB
01_random_11.txt AC 85 ms 54056 KiB
01_random_12.txt AC 84 ms 51700 KiB
01_random_13.txt AC 98 ms 55972 KiB
01_random_14.txt AC 84 ms 47248 KiB
01_random_15.txt AC 98 ms 56032 KiB
01_random_16.txt AC 108 ms 56072 KiB
01_random_17.txt AC 106 ms 56020 KiB
01_random_18.txt AC 102 ms 56072 KiB
01_random_19.txt AC 109 ms 56092 KiB
01_random_20.txt AC 103 ms 55988 KiB
01_random_21.txt AC 108 ms 56080 KiB
01_random_22.txt AC 108 ms 55836 KiB
01_random_23.txt AC 64 ms 38608 KiB
01_random_24.txt AC 45 ms 25972 KiB
01_random_25.txt AC 41 ms 26096 KiB
01_random_26.txt AC 55 ms 27356 KiB
01_random_27.txt AC 50 ms 25872 KiB
01_random_28.txt AC 51 ms 25724 KiB