結果

問題 No.1355 AND OR GAME
ユーザー さかぽんさかぽん
提出日時 2021-01-24 13:19:52
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,965 bytes
コンパイル時間 4,023 ms
コンパイル使用メモリ 107,608 KB
実行使用メモリ 164,928 KB
最終ジャッジ日時 2023-08-30 20:42:36
合計ジャッジ時間 38,829 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
19,728 KB
testcase_01 AC 61 ms
21,840 KB
testcase_02 AC 71 ms
24,012 KB
testcase_03 AC 72 ms
24,024 KB
testcase_04 AC 72 ms
21,984 KB
testcase_05 AC 64 ms
23,776 KB
testcase_06 AC 71 ms
21,980 KB
testcase_07 AC 71 ms
21,940 KB
testcase_08 AC 71 ms
22,012 KB
testcase_09 AC 70 ms
23,940 KB
testcase_10 AC 64 ms
21,860 KB
testcase_11 AC 62 ms
23,800 KB
testcase_12 AC 63 ms
23,824 KB
testcase_13 AC 63 ms
21,696 KB
testcase_14 AC 62 ms
21,764 KB
testcase_15 AC 63 ms
21,768 KB
testcase_16 AC 63 ms
23,688 KB
testcase_17 AC 63 ms
21,796 KB
testcase_18 AC 62 ms
19,672 KB
testcase_19 AC 61 ms
21,676 KB
testcase_20 AC 63 ms
21,672 KB
testcase_21 AC 62 ms
19,808 KB
testcase_22 AC 64 ms
21,788 KB
testcase_23 AC 61 ms
21,848 KB
testcase_24 AC 63 ms
23,868 KB
testcase_25 AC 62 ms
21,780 KB
testcase_26 AC 63 ms
21,724 KB
testcase_27 AC 60 ms
21,824 KB
testcase_28 AC 64 ms
23,768 KB
testcase_29 AC 63 ms
19,816 KB
testcase_30 AC 62 ms
21,808 KB
testcase_31 AC 64 ms
21,800 KB
testcase_32 AC 65 ms
23,820 KB
testcase_33 AC 66 ms
21,800 KB
testcase_34 AC 85 ms
23,788 KB
testcase_35 AC 230 ms
53,240 KB
testcase_36 AC 219 ms
45,820 KB
testcase_37 AC 61 ms
15,620 KB
testcase_38 AC 232 ms
47,312 KB
testcase_39 AC 125 ms
31,860 KB
testcase_40 AC 150 ms
36,816 KB
testcase_41 AC 232 ms
47,172 KB
testcase_42 AC 231 ms
47,240 KB
testcase_43 AC 161 ms
40,000 KB
testcase_44 AC 91 ms
21,268 KB
testcase_45 AC 231 ms
47,292 KB
testcase_46 AC 131 ms
32,880 KB
testcase_47 AC 233 ms
47,088 KB
testcase_48 AC 188 ms
41,596 KB
testcase_49 AC 233 ms
47,168 KB
testcase_50 AC 60 ms
15,696 KB
testcase_51 AC 151 ms
37,316 KB
testcase_52 AC 212 ms
44,832 KB
testcase_53 AC 168 ms
39,268 KB
testcase_54 AC 235 ms
47,172 KB
testcase_55 AC 203 ms
45,684 KB
testcase_56 AC 203 ms
45,716 KB
testcase_57 AC 186 ms
41,012 KB
testcase_58 AC 98 ms
23,416 KB
testcase_59 AC 61 ms
15,704 KB
testcase_60 AC 180 ms
39,968 KB
testcase_61 AC 60 ms
15,720 KB
testcase_62 AC 132 ms
33,416 KB
testcase_63 AC 232 ms
47,288 KB
testcase_64 AC 204 ms
45,608 KB
testcase_65 AC 69 ms
16,104 KB
testcase_66 AC 115 ms
30,632 KB
testcase_67 AC 123 ms
30,720 KB
testcase_68 AC 119 ms
30,644 KB
testcase_69 AC 61 ms
15,700 KB
testcase_70 AC 130 ms
32,988 KB
testcase_71 AC 233 ms
47,180 KB
testcase_72 AC 233 ms
47,160 KB
testcase_73 AC 234 ms
47,168 KB
testcase_74 AC 237 ms
47,192 KB
testcase_75 AC 234 ms
47,184 KB
testcase_76 AC 232 ms
47,180 KB
testcase_77 AC 233 ms
47,096 KB
testcase_78 AC 61 ms
21,872 KB
testcase_79 AC 61 ms
21,832 KB
testcase_80 AC 228 ms
51,172 KB
testcase_81 AC 233 ms
47,056 KB
testcase_82 AC 230 ms
51,248 KB
testcase_83 AC 204 ms
45,708 KB
testcase_84 AC 493 ms
66,684 KB
testcase_85 AC 1,555 ms
128,764 KB
testcase_86 AC 925 ms
91,132 KB
testcase_87 AC 706 ms
84,720 KB
testcase_88 AC 104 ms
29,412 KB
testcase_89 AC 81 ms
25,344 KB
testcase_90 TLE -
testcase_91 AC 174 ms
45,080 KB
testcase_92 AC 119 ms
33,180 KB
testcase_93 AC 1,882 ms
134,524 KB
testcase_94 AC 923 ms
87,960 KB
testcase_95 AC 646 ms
70,100 KB
testcase_96 AC 457 ms
59,720 KB
testcase_97 AC 120 ms
24,868 KB
testcase_98 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 Match(bool x, bool? y) => y == null || x == y;
		bool Matches(bool[] x, bool?[] y) => Array.TrueForAll(r60, i => Match(x[i], y[i]));

		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++)
					{
						var mt = Match(af[f] & true, yf[f]);
						var mf = Match(af[f] & false, yf[f]);
						if (mt && mf) { }
						else if (mt) t[f] = true;
						else if (mf) 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++)
					{
						var mt = Match(af[f] | true, yf[f]);
						var mf = Match(af[f] | false, yf[f]);
						if (mt && mf) { }
						else if (mt) t[f] = true;
						else if (mf) 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