提出 #33110149


ソースコード 拡げる

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;

namespace Tasks
{
    public class C
    {
        public static void Main()
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var S = Scanner.Scan<string>();
            var T = Scanner.Scan<string>();

            List<(char, int)> F(ReadOnlySpan<char> s)
            {
                var result = new List<(char, int)>();
                var r = 0;
                for (var l = 0; l < s.Length;)
                {
                    r = l;
                    while (r < s.Length && s[r] == s[l]) r++;
                    result.Add((s[l], r - l));
                    l = r;
                }

                return result;
            }

            var ss = F(S);
            var tt = F(T);
            var answer = ss.Count == tt.Count;
            if (answer)
            {
                for (var i = 0; i < ss.Count; i++)
                {
                    var (s, cs) = ss[i];
                    var (t, ct) = tt[i];
                    answer &= s == t;
                    answer &= cs == ct || cs > 1 && ct > 1 && cs < ct;
                }
            }

            // Console.WriteLine(string.Join(" ", ss));
            // Console.WriteLine(string.Join(" ", tt));

            Console.WriteLine(answer ? "Yes" : "No");
        }

        public static class Scanner
        {
            public static string ScanLine() => Console.ReadLine()?.Trim() ?? string.Empty;
            public static string[] Scan() => ScanLine().Split(' ');
            public static T Scan<T>() where T : IConvertible => Convert<T>(Scan()[0]);
            public static (T1, T2) Scan<T1, T2>() where T1 : IConvertible where T2 : IConvertible
            {
                var line = Scan();
                return (Convert<T1>(line[0]), Convert<T2>(line[1]));
            }
            public static (T1, T2, T3) Scan<T1, T2, T3>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible
            {
                var line = Scan();
                return (Convert<T1>(line[0]), Convert<T2>(line[1]), Convert<T3>(line[2]));
            }
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible where T4 : IConvertible
            {
                var line = Scan();
                return (Convert<T1>(line[0]), Convert<T2>(line[1]), Convert<T3>(line[2]), Convert<T4>(line[3]));
            }
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible where T4 : IConvertible where T5 : IConvertible
            {
                var line = Scan();
                return (Convert<T1>(line[0]), Convert<T2>(line[1]), Convert<T3>(line[2]), Convert<T4>(line[3]), Convert<T5>(line[4]));
            }
            public static (T1, T2, T3, T4, T5, T6) Scan<T1, T2, T3, T4, T5, T6>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible where T4 : IConvertible where T5 : IConvertible where T6 : IConvertible
            {
                var line = Scan();
                return (Convert<T1>(line[0]), Convert<T2>(line[1]), Convert<T3>(line[2]), Convert<T4>(line[3]), Convert<T5>(line[4]), Convert<T6>(line[5]));
            }
            public static IEnumerable<T> ScanEnumerable<T>() where T : IConvertible => Scan().Select(Convert<T>);
            private static T Convert<T>(string value) where T : IConvertible => (T)System.Convert.ChangeType(value, typeof(T));
        }
    }
}

提出情報

提出日時
問題 C - XX to XXX
ユーザ AconCavy
言語 C# (.NET Core 3.1.201)
得点 300
コード長 3951 Byte
結果 AC
実行時間 105 ms
メモリ 33244 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 2
AC × 32
セット名 テストケース
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, example0.txt, example1.txt
ケース名 結果 実行時間 メモリ
000.txt AC 84 ms 26024 KiB
001.txt AC 82 ms 27436 KiB
002.txt AC 87 ms 26700 KiB
003.txt AC 83 ms 30676 KiB
004.txt AC 89 ms 31916 KiB
005.txt AC 91 ms 33164 KiB
006.txt AC 87 ms 33244 KiB
007.txt AC 91 ms 33032 KiB
008.txt AC 81 ms 26912 KiB
009.txt AC 88 ms 27156 KiB
010.txt AC 74 ms 27356 KiB
011.txt AC 83 ms 27568 KiB
012.txt AC 84 ms 31344 KiB
013.txt AC 94 ms 32816 KiB
014.txt AC 105 ms 33012 KiB
015.txt AC 84 ms 32988 KiB
016.txt AC 78 ms 27112 KiB
017.txt AC 82 ms 27216 KiB
018.txt AC 85 ms 27096 KiB
019.txt AC 79 ms 26992 KiB
020.txt AC 92 ms 27004 KiB
021.txt AC 80 ms 27100 KiB
022.txt AC 92 ms 27300 KiB
023.txt AC 95 ms 27300 KiB
024.txt AC 98 ms 27008 KiB
025.txt AC 83 ms 32368 KiB
026.txt AC 82 ms 28232 KiB
027.txt AC 94 ms 32988 KiB
028.txt AC 95 ms 33060 KiB
029.txt AC 95 ms 33024 KiB
example0.txt AC 84 ms 25920 KiB
example1.txt AC 79 ms 25948 KiB