結果

問題 No.2209 Flip and Reverse
ユーザー bluemeganebluemegane
提出日時 2023-02-11 17:31:22
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 905 bytes
コンパイル時間 1,362 ms
コンパイル使用メモリ 70,024 KB
実行使用メモリ 32,844 KB
最終ジャッジ日時 2023-09-22 13:55:53
合計ジャッジ時間 6,677 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
23,544 KB
testcase_01 AC 56 ms
23,592 KB
testcase_02 AC 55 ms
21,404 KB
testcase_03 AC 56 ms
21,468 KB
testcase_04 AC 55 ms
21,480 KB
testcase_05 AC 57 ms
21,580 KB
testcase_06 AC 57 ms
21,624 KB
testcase_07 AC 59 ms
21,644 KB
testcase_08 AC 103 ms
28,900 KB
testcase_09 AC 57 ms
23,468 KB
testcase_10 AC 57 ms
19,464 KB
testcase_11 AC 55 ms
21,372 KB
testcase_12 AC 58 ms
23,588 KB
testcase_13 AC 57 ms
21,488 KB
testcase_14 AC 130 ms
28,708 KB
testcase_15 AC 127 ms
30,736 KB
testcase_16 AC 127 ms
32,744 KB
testcase_17 AC 127 ms
30,832 KB
testcase_18 AC 123 ms
28,776 KB
testcase_19 AC 123 ms
30,820 KB
testcase_20 AC 126 ms
30,732 KB
testcase_21 AC 126 ms
32,740 KB
testcase_22 AC 125 ms
30,760 KB
testcase_23 AC 123 ms
28,860 KB
testcase_24 AC 113 ms
30,796 KB
testcase_25 AC 118 ms
32,780 KB
testcase_26 AC 113 ms
28,868 KB
testcase_27 AC 113 ms
30,896 KB
testcase_28 AC 105 ms
30,844 KB
testcase_29 AC 106 ms
32,844 KB
testcase_30 AC 102 ms
28,804 KB
testcase_31 AC 106 ms
30,736 KB
testcase_32 AC 102 ms
30,928 KB
testcase_33 AC 104 ms
28,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Hello
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var s = Console.ReadLine().Trim();
        var t = Console.ReadLine().Trim();
        getAns(n, s, t);
    }
    static void getAns(int n, string s, string t)
    {
        var cs1 = s.Count(x => x == '1');
        var ct1 = t.Count(x => x == '1');
        var d = Abs(cs1 - ct1);
        var c = 0;
        if (d % 2 == 0)
        {
            for (int i = 0; i < n; i++)
            {
                if (s[i] != t[i]) c++;
            }
        }
        else
        {
            var t2 = t.ToCharArray();
            Array.Reverse(t2);
            for (int i = 0; i < n; i++)
            {
                if (s[i] != t2[i]) c++;
            }
        }
        Console.WriteLine(c);
    }
}
0