結果

問題 No.2629 A replace B replace C
ユーザー tobisatistobisatis
提出日時 2024-02-16 22:20:47
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 2,203 bytes
コンパイル時間 10,220 ms
コンパイル使用メモリ 158,920 KB
実行使用メモリ 177,948 KB
最終ジャッジ日時 2024-02-16 22:21:05
合計ジャッジ時間 14,093 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
34,596 KB
testcase_01 AC 63 ms
32,804 KB
testcase_02 AC 63 ms
32,676 KB
testcase_03 AC 64 ms
33,828 KB
testcase_04 AC 61 ms
31,908 KB
testcase_05 AC 68 ms
32,676 KB
testcase_06 AC 62 ms
32,548 KB
testcase_07 AC 62 ms
32,676 KB
testcase_08 AC 65 ms
32,932 KB
testcase_09 AC 66 ms
33,316 KB
testcase_10 AC 66 ms
33,060 KB
testcase_11 AC 65 ms
33,188 KB
testcase_12 AC 64 ms
33,444 KB
testcase_13 AC 64 ms
32,548 KB
testcase_14 AC 65 ms
33,188 KB
testcase_15 AC 66 ms
33,060 KB
testcase_16 AC 67 ms
32,676 KB
testcase_17 AC 64 ms
33,060 KB
testcase_18 AC 64 ms
33,188 KB
testcase_19 AC 65 ms
32,420 KB
testcase_20 AC 63 ms
32,676 KB
testcase_21 AC 65 ms
33,188 KB
testcase_22 AC 64 ms
32,676 KB
testcase_23 AC 67 ms
33,188 KB
testcase_24 AC 64 ms
33,188 KB
testcase_25 AC 64 ms
32,932 KB
testcase_26 AC 64 ms
32,804 KB
testcase_27 AC 64 ms
32,548 KB
testcase_28 AC 66 ms
33,188 KB
testcase_29 AC 65 ms
32,548 KB
testcase_30 AC 64 ms
32,164 KB
testcase_31 AC 65 ms
33,444 KB
testcase_32 AC 65 ms
33,316 KB
testcase_33 AC 67 ms
33,956 KB
testcase_34 AC 65 ms
33,060 KB
testcase_35 AC 65 ms
33,316 KB
testcase_36 AC 65 ms
33,700 KB
testcase_37 AC 65 ms
33,572 KB
testcase_38 AC 64 ms
33,572 KB
testcase_39 AC 65 ms
33,060 KB
testcase_40 AC 64 ms
33,444 KB
testcase_41 AC 65 ms
32,676 KB
testcase_42 AC 66 ms
32,932 KB
testcase_43 AC 64 ms
32,932 KB
testcase_44 AC 65 ms
33,060 KB
testcase_45 AC 66 ms
33,316 KB
testcase_46 AC 66 ms
33,700 KB
testcase_47 AC 64 ms
33,060 KB
testcase_48 AC 64 ms
32,804 KB
testcase_49 AC 65 ms
32,548 KB
testcase_50 AC 65 ms
33,060 KB
testcase_51 AC 64 ms
32,804 KB
testcase_52 AC 64 ms
33,060 KB
testcase_53 AC 63 ms
32,164 KB
testcase_54 AC 63 ms
32,292 KB
testcase_55 AC 67 ms
32,420 KB
testcase_56 AC 65 ms
32,036 KB
testcase_57 AC 66 ms
32,932 KB
testcase_58 AC 63 ms
32,420 KB
testcase_59 AC 67 ms
33,316 KB
testcase_60 AC 66 ms
32,676 KB
testcase_61 AC 60 ms
31,140 KB
testcase_62 AC 60 ms
31,140 KB
testcase_63 AC 60 ms
31,140 KB
testcase_64 AC 60 ms
31,140 KB
testcase_65 AC 59 ms
177,948 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (110 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

namespace AtCoder;

#nullable enable

using System.Numerics;

static class Extensions
{
    public static T[] Repeat<T>(this int time, Func<T> F) => Enumerable.Range(0, time).Select(_ => F()).ToArray();
}

class AtCoder
{
    object? Solve()
    {
        var n = Int();
        var s = new int[n];
        var t = new int[n];
        {
            var r = String();
            for (var i = 0; i < n; i++) s[i] = r[i] - 'A';
        }
        {
            var r = String();
            for (var i = 0; i < n; i++) t[i] = r[i] - 'A';
        }
        var d = new int[3];
        for (var i = 0; i < n; i++)
        {
            if (s[i] > t[i]) return false;
            if (s[i] == 0)
            {
                if (t[i] == 1) d[0]++;
                if (t[i] == 2) d[2]++;
            }
            if (s[i] == 1)
            {
                if (t[i] == 2) d[1]++;
            }
        }
        if (d[2] > 0 && d[1] == 0) return false;
        return d[0] == d[1];
        
    }

    public static void Main() => new AtCoder().Run();
    public void Run()
    {
        var res = Solve();
        if (res != null)
        {
            if (res is bool yes) res = yes ? "Yes" : "No";
            sw.WriteLine(res);
        }
        sw.Flush();
    }

    string[] input = Array.Empty<string>();
    int iter = 0;
    readonly StreamWriter sw = new(Console.OpenStandardOutput()) { AutoFlush = false };

    #pragma warning disable IDE0051
    string String()
    {
        while (iter >= input.Length) (input, iter) = (Console.ReadLine()!.Split(' '), 0);
        return input[iter++];
    }
    T Input<T>() where T : IParsable<T> => T.Parse(String(), null);
    int Int() => Input<int>();
    void Out(object? x, string? separator = null)
    {
        separator ??= Environment.NewLine;
        if (x is System.Collections.IEnumerable obj and not string)
        {
            var firstLine = true;
            foreach (var item in obj)
            {
                if (!firstLine) sw.Write(separator);
                firstLine = false;
                sw.Write(item);
            }
        }
        else sw.Write(x);
        sw.WriteLine();
    }
    #pragma warning restore IDE0051
}
0