結果

問題 No.1355 AND OR GAME
ユーザー さかぽんさかぽん
提出日時 2021-01-24 02:37:50
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,840 bytes
コンパイル時間 4,855 ms
コンパイル使用メモリ 107,868 KB
実行使用メモリ 130,328 KB
最終ジャッジ日時 2023-08-30 13:51:46
合計ジャッジ時間 43,030 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
19,768 KB
testcase_01 AC 66 ms
23,708 KB
testcase_02 AC 75 ms
21,988 KB
testcase_03 AC 73 ms
24,012 KB
testcase_04 AC 74 ms
22,040 KB
testcase_05 AC 67 ms
21,812 KB
testcase_06 AC 73 ms
22,084 KB
testcase_07 AC 73 ms
21,976 KB
testcase_08 AC 73 ms
21,964 KB
testcase_09 AC 73 ms
21,924 KB
testcase_10 AC 65 ms
23,820 KB
testcase_11 AC 64 ms
21,804 KB
testcase_12 AC 68 ms
21,756 KB
testcase_13 AC 63 ms
21,800 KB
testcase_14 AC 63 ms
21,920 KB
testcase_15 AC 64 ms
21,788 KB
testcase_16 WA -
testcase_17 AC 65 ms
23,812 KB
testcase_18 WA -
testcase_19 AC 64 ms
23,776 KB
testcase_20 AC 65 ms
21,764 KB
testcase_21 AC 67 ms
21,716 KB
testcase_22 AC 64 ms
21,852 KB
testcase_23 AC 64 ms
21,792 KB
testcase_24 AC 63 ms
21,828 KB
testcase_25 AC 66 ms
23,756 KB
testcase_26 AC 67 ms
21,756 KB
testcase_27 AC 62 ms
23,808 KB
testcase_28 AC 67 ms
21,768 KB
testcase_29 AC 65 ms
19,876 KB
testcase_30 AC 65 ms
23,988 KB
testcase_31 AC 66 ms
21,700 KB
testcase_32 AC 66 ms
21,628 KB
testcase_33 AC 65 ms
21,832 KB
testcase_34 WA -
testcase_35 AC 239 ms
54,828 KB
testcase_36 WA -
testcase_37 AC 64 ms
15,712 KB
testcase_38 WA -
testcase_39 AC 126 ms
31,908 KB
testcase_40 AC 152 ms
35,904 KB
testcase_41 AC 237 ms
46,732 KB
testcase_42 WA -
testcase_43 AC 160 ms
46,264 KB
testcase_44 WA -
testcase_45 AC 237 ms
50,700 KB
testcase_46 AC 134 ms
40,032 KB
testcase_47 WA -
testcase_48 AC 195 ms
47,712 KB
testcase_49 WA -
testcase_50 AC 64 ms
21,888 KB
testcase_51 AC 156 ms
42,436 KB
testcase_52 WA -
testcase_53 AC 171 ms
47,440 KB
testcase_54 AC 238 ms
54,780 KB
testcase_55 AC 207 ms
45,660 KB
testcase_56 AC 207 ms
45,692 KB
testcase_57 AC 189 ms
41,032 KB
testcase_58 AC 101 ms
22,812 KB
testcase_59 AC 65 ms
15,712 KB
testcase_60 AC 181 ms
40,092 KB
testcase_61 AC 65 ms
15,732 KB
testcase_62 AC 135 ms
33,440 KB
testcase_63 AC 236 ms
46,628 KB
testcase_64 AC 208 ms
45,864 KB
testcase_65 WA -
testcase_66 AC 118 ms
34,940 KB
testcase_67 AC 126 ms
40,488 KB
testcase_68 WA -
testcase_69 AC 64 ms
23,716 KB
testcase_70 AC 136 ms
40,148 KB
testcase_71 WA -
testcase_72 AC 238 ms
52,812 KB
testcase_73 AC 237 ms
52,732 KB
testcase_74 WA -
testcase_75 WA -
testcase_76 AC 238 ms
52,928 KB
testcase_77 WA -
testcase_78 AC 65 ms
21,748 KB
testcase_79 AC 67 ms
23,880 KB
testcase_80 AC 237 ms
52,704 KB
testcase_81 WA -
testcase_82 WA -
testcase_83 AC 210 ms
53,732 KB
testcase_84 AC 398 ms
62,212 KB
testcase_85 AC 1,232 ms
105,676 KB
testcase_86 AC 612 ms
78,840 KB
testcase_87 AC 579 ms
73,304 KB
testcase_88 AC 91 ms
28,060 KB
testcase_89 AC 83 ms
27,200 KB
testcase_90 AC 1,613 ms
128,768 KB
testcase_91 AC 150 ms
42,648 KB
testcase_92 AC 111 ms
31,956 KB
testcase_93 AC 1,238 ms
109,644 KB
testcase_94 AC 589 ms
80,340 KB
testcase_95 AC 411 ms
65,192 KB
testcase_96 AC 293 ms
61,056 KB
testcase_97 AC 104 ms
31,040 KB
testcase_98 AC 1,590 ms
130,328 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.Generic;
using System.Linq;

class F
{
	static long[] ReadL() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
	static (long, long, long) Read3L() { var a = ReadL(); return (a[0], a[1], a[2]); }
	static void Main() => Console.WriteLine(Solve());
	static object Solve()
	{
		var (n, x, y) = ((int, long, long))Read3L();
		var a = ReadL();

		var r60 = Enumerable.Range(0, 60).ToArray();
		bool[] ToBool(long v) => Array.ConvertAll(r60, i => (v & (1 << i)) != 0);
		bool?[] ToBoolN(long v) => Array.ConvertAll(r60, i => (bool?)((v & (1 << i)) != 0));
		bool Matches(bool[] x, bool?[] y) => Array.TrueForAll(r60, i => (x[i] ^ y[i]) != true);

		var p = new Stack<int>();
		var xf = ToBool(x);

		bool Dfs(int i, bool?[] yf)
		{
			if (i < 0)
			{
				return Matches(xf, yf);
			}
			else
			{
				var af = ToBool(a[i]);

				if (Matches(af, yf))
				{
					p.Push(3);
					return true;
				}

				var ok = true;
				var t = new bool?[60];

				for (int f = 0; f < 60; f++)
				{
					if (yf[f] == null || (af[f] & null) == yf[f]) { }
					else if ((af[f] & true) == yf[f]) t[f] = true;
					else if ((af[f] & false) == yf[f]) t[f] = false;
					else { ok = false; break; }
				}
				if (ok)
				{
					p.Push(1);
					if (Dfs(i - 1, t)) return true;
					p.Pop();
				}

				ok = true;
				Array.Clear(t, 0, 60);

				for (int f = 0; f < 60; f++)
				{
					if (yf[f] == null || (af[f] | null) == yf[f]) { }
					else if ((af[f] | true) == yf[f]) t[f] = true;
					else if ((af[f] | false) == yf[f]) t[f] = false;
					else { ok = false; break; }
				}
				if (ok)
				{
					p.Push(2);
					if (Dfs(i - 1, t)) return true;
					p.Pop();
				}

				return false;
			}
		}

		if (!Dfs(n - 1, ToBoolN(y))) return -1;
		return string.Join(" ", Enumerable.Repeat(1, n - p.Count).Concat(p));
	}
}
0