結果

問題 No.1355 AND OR GAME
ユーザー さかぽんさかぽん
提出日時 2021-01-24 13:27:45
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 1,995 ms / 2,000 ms
コード長 1,891 bytes
コンパイル時間 2,741 ms
コンパイル使用メモリ 105,876 KB
実行使用メモリ 159,744 KB
最終ジャッジ日時 2023-08-30 20:51:03
合計ジャッジ時間 32,267 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
23,744 KB
testcase_01 AC 62 ms
23,692 KB
testcase_02 AC 70 ms
19,928 KB
testcase_03 AC 71 ms
23,940 KB
testcase_04 AC 69 ms
21,880 KB
testcase_05 AC 63 ms
21,724 KB
testcase_06 AC 69 ms
21,900 KB
testcase_07 AC 70 ms
23,884 KB
testcase_08 AC 69 ms
21,968 KB
testcase_09 AC 69 ms
21,904 KB
testcase_10 AC 63 ms
21,620 KB
testcase_11 AC 61 ms
21,696 KB
testcase_12 AC 62 ms
21,680 KB
testcase_13 AC 61 ms
23,700 KB
testcase_14 AC 60 ms
21,700 KB
testcase_15 AC 61 ms
21,708 KB
testcase_16 AC 63 ms
21,668 KB
testcase_17 AC 61 ms
21,620 KB
testcase_18 AC 63 ms
21,740 KB
testcase_19 AC 61 ms
21,708 KB
testcase_20 AC 63 ms
21,664 KB
testcase_21 AC 62 ms
21,764 KB
testcase_22 AC 62 ms
21,656 KB
testcase_23 AC 62 ms
23,740 KB
testcase_24 AC 61 ms
21,692 KB
testcase_25 AC 62 ms
19,588 KB
testcase_26 AC 62 ms
21,676 KB
testcase_27 AC 61 ms
21,632 KB
testcase_28 AC 63 ms
21,644 KB
testcase_29 AC 63 ms
23,780 KB
testcase_30 AC 65 ms
23,824 KB
testcase_31 AC 63 ms
23,692 KB
testcase_32 AC 62 ms
21,640 KB
testcase_33 AC 63 ms
23,760 KB
testcase_34 AC 83 ms
23,776 KB
testcase_35 AC 226 ms
51,208 KB
testcase_36 AC 212 ms
51,832 KB
testcase_37 AC 62 ms
23,732 KB
testcase_38 AC 226 ms
55,156 KB
testcase_39 AC 120 ms
39,848 KB
testcase_40 AC 147 ms
44,940 KB
testcase_41 AC 227 ms
51,112 KB
testcase_42 AC 225 ms
55,376 KB
testcase_43 AC 155 ms
48,020 KB
testcase_44 AC 90 ms
28,720 KB
testcase_45 AC 226 ms
55,296 KB
testcase_46 AC 127 ms
39,052 KB
testcase_47 AC 226 ms
53,248 KB
testcase_48 AC 185 ms
49,604 KB
testcase_49 AC 225 ms
53,216 KB
testcase_50 AC 61 ms
21,724 KB
testcase_51 AC 148 ms
41,264 KB
testcase_52 AC 210 ms
50,916 KB
testcase_53 AC 164 ms
47,292 KB
testcase_54 AC 226 ms
51,116 KB
testcase_55 AC 197 ms
51,708 KB
testcase_56 AC 199 ms
51,752 KB
testcase_57 AC 180 ms
49,016 KB
testcase_58 AC 96 ms
30,284 KB
testcase_59 AC 61 ms
21,584 KB
testcase_60 AC 174 ms
46,092 KB
testcase_61 AC 61 ms
23,728 KB
testcase_62 AC 128 ms
41,484 KB
testcase_63 AC 227 ms
53,212 KB
testcase_64 AC 198 ms
53,828 KB
testcase_65 AC 69 ms
24,028 KB
testcase_66 AC 112 ms
38,852 KB
testcase_67 AC 119 ms
36,908 KB
testcase_68 AC 118 ms
38,684 KB
testcase_69 AC 62 ms
21,736 KB
testcase_70 AC 129 ms
39,024 KB
testcase_71 AC 228 ms
53,184 KB
testcase_72 AC 225 ms
53,284 KB
testcase_73 AC 226 ms
53,252 KB
testcase_74 AC 227 ms
55,116 KB
testcase_75 AC 225 ms
55,220 KB
testcase_76 AC 228 ms
55,212 KB
testcase_77 AC 227 ms
55,216 KB
testcase_78 AC 61 ms
21,716 KB
testcase_79 AC 62 ms
23,696 KB
testcase_80 AC 228 ms
55,260 KB
testcase_81 AC 228 ms
55,176 KB
testcase_82 AC 227 ms
53,148 KB
testcase_83 AC 198 ms
51,660 KB
testcase_84 AC 395 ms
71,356 KB
testcase_85 AC 1,229 ms
125,436 KB
testcase_86 AC 740 ms
90,060 KB
testcase_87 AC 564 ms
82,288 KB
testcase_88 AC 95 ms
29,188 KB
testcase_89 AC 78 ms
25,196 KB
testcase_90 AC 1,912 ms
146,748 KB
testcase_91 AC 150 ms
44,488 KB
testcase_92 AC 107 ms
32,864 KB
testcase_93 AC 1,514 ms
136,360 KB
testcase_94 AC 725 ms
89,304 KB
testcase_95 AC 509 ms
75,436 KB
testcase_96 AC 367 ms
66,760 KB
testcase_97 AC 103 ms
32,628 KB
testcase_98 AC 1,995 ms
159,744 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 & (1L << i)) != 0);
		bool?[] ToBoolN(long v) => Array.ConvertAll(r60, i => (bool?)((v & (1L << 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);
					while (p.Count < n) p.Push(1);
					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();
					}
				}
				{
					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(2);
						if (Dfs(i - 1, t)) return true;
						p.Pop();
					}
				}
				return false;
			}
		}

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