結果
| 問題 |
No.1377 Half xor Half
|
| コンテスト | |
| ユーザー |
keymoon
|
| 提出日時 | 2021-02-05 22:42:50 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 2,000 ms |
| コード長 | 1,967 bytes |
| コンパイル時間 | 3,465 ms |
| コンパイル使用メモリ | 114,516 KB |
| 実行使用メモリ | 27,000 KB |
| 最終ジャッジ日時 | 2024-07-02 13:25:44 |
| 合計ジャッジ時間 | 6,461 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 46 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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));
}
}
keymoon