結果

問題 No.1377 Half xor Half
ユーザー keymoonkeymoon
提出日時 2021-02-05 22:42:50
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 1,967 bytes
コンパイル時間 8,199 ms
コンパイル使用メモリ 105,116 KB
実行使用メモリ 23,932 KB
最終ジャッジ日時 2023-09-15 09:23:57
合計ジャッジ時間 12,054 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
21,628 KB
testcase_01 AC 62 ms
21,612 KB
testcase_02 AC 65 ms
21,712 KB
testcase_03 AC 63 ms
21,624 KB
testcase_04 AC 65 ms
23,616 KB
testcase_05 AC 66 ms
21,668 KB
testcase_06 AC 67 ms
21,752 KB
testcase_07 AC 68 ms
23,716 KB
testcase_08 AC 69 ms
21,744 KB
testcase_09 AC 67 ms
23,844 KB
testcase_10 AC 69 ms
21,796 KB
testcase_11 AC 66 ms
19,596 KB
testcase_12 AC 67 ms
21,792 KB
testcase_13 AC 68 ms
23,672 KB
testcase_14 AC 62 ms
21,616 KB
testcase_15 AC 63 ms
19,744 KB
testcase_16 AC 65 ms
21,660 KB
testcase_17 AC 65 ms
21,688 KB
testcase_18 AC 68 ms
21,772 KB
testcase_19 AC 69 ms
21,788 KB
testcase_20 AC 68 ms
23,704 KB
testcase_21 AC 69 ms
23,932 KB
testcase_22 AC 69 ms
21,668 KB
testcase_23 AC 70 ms
23,744 KB
testcase_24 AC 70 ms
23,696 KB
testcase_25 AC 70 ms
23,696 KB
testcase_26 AC 69 ms
23,792 KB
testcase_27 AC 68 ms
21,764 KB
testcase_28 AC 69 ms
21,728 KB
testcase_29 AC 71 ms
21,660 KB
testcase_30 AC 64 ms
19,700 KB
testcase_31 AC 65 ms
21,700 KB
testcase_32 AC 67 ms
21,788 KB
testcase_33 AC 67 ms
23,772 KB
testcase_34 AC 71 ms
23,708 KB
testcase_35 AC 71 ms
21,628 KB
testcase_36 AC 72 ms
21,816 KB
testcase_37 AC 65 ms
21,756 KB
testcase_38 AC 72 ms
21,812 KB
testcase_39 AC 76 ms
21,788 KB
testcase_40 AC 73 ms
21,616 KB
testcase_41 AC 67 ms
21,660 KB
testcase_42 AC 72 ms
21,688 KB
testcase_43 AC 71 ms
23,712 KB
testcase_44 AC 72 ms
21,824 KB
testcase_45 AC 66 ms
21,652 KB
testcase_46 AC 72 ms
21,824 KB
testcase_47 AC 72 ms
21,852 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine().ToArray();
        var t = Console.ReadLine().ToArray();
        List<int> ops = new List<int>();
        void Operation(int x)
        {
            ops.Add(x);
            for (int i = 0; i < n; i++)
            {
                var a = (x + i) % (2 * n);
                var b = (x + i + n) % (2 * n);
                s[a] = (char)(s[a] ^ s[b] ^ '0'); 
            }
        }
        bool Action(string a, string b, int ind)
        {
            if (a == b) return true;
            if (a == "00" || b == "00") return false;
            int first = -1;
            if (a == "11")
            {
                if (b == "01") first = 0;
                if (b == "10") first = 1;
            }
            else if (b == "11")
            {
                if (a == "10") first = 0;
                if (a == "01") first = 1;
            }
            else
            {
                if (a == "01") first = 0;
                if (a == "10") first = 1;
            }
            Operation(ind + first);
            int second = first == 1 ? 0 : 1;
            Operation(ind + second);
            return true;
        }
        for (int i = 0; i < n; i++)
        {
            var prev = $"{s[i]}{s[i + n]}";
            var after = $"{t[i]}{t[i + n]}";
            if (!Action(prev, after, i))
            {
                Console.WriteLine(-1);
                return;
            }
        }
        if (!s.SequenceEqual(t)) throw new Exception();
        Console.WriteLine(ops.Count);
        Console.WriteLine(string.Join("\n", ops));
    }
}
0