結果

問題 No.1355 AND OR GAME
ユーザー さかぽんさかぽん
提出日時 2021-01-24 17:41:26
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 328 ms / 2,000 ms
コード長 1,612 bytes
コンパイル時間 3,433 ms
コンパイル使用メモリ 106,728 KB
実行使用メモリ 57,416 KB
最終ジャッジ日時 2023-08-31 01:27:45
合計ジャッジ時間 27,075 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
21,960 KB
testcase_01 AC 63 ms
21,844 KB
testcase_02 AC 70 ms
21,940 KB
testcase_03 AC 70 ms
22,028 KB
testcase_04 AC 70 ms
22,020 KB
testcase_05 AC 60 ms
23,776 KB
testcase_06 AC 71 ms
22,080 KB
testcase_07 AC 70 ms
22,032 KB
testcase_08 AC 70 ms
21,932 KB
testcase_09 AC 70 ms
23,932 KB
testcase_10 AC 62 ms
21,908 KB
testcase_11 AC 60 ms
23,760 KB
testcase_12 AC 63 ms
23,744 KB
testcase_13 AC 62 ms
23,776 KB
testcase_14 AC 62 ms
23,748 KB
testcase_15 AC 64 ms
21,944 KB
testcase_16 AC 63 ms
23,724 KB
testcase_17 AC 63 ms
21,756 KB
testcase_18 AC 63 ms
21,724 KB
testcase_19 AC 61 ms
21,788 KB
testcase_20 AC 62 ms
21,720 KB
testcase_21 AC 60 ms
23,768 KB
testcase_22 AC 61 ms
21,844 KB
testcase_23 AC 60 ms
21,804 KB
testcase_24 AC 61 ms
21,752 KB
testcase_25 AC 62 ms
23,896 KB
testcase_26 AC 61 ms
21,716 KB
testcase_27 AC 60 ms
21,960 KB
testcase_28 AC 61 ms
23,816 KB
testcase_29 AC 64 ms
23,828 KB
testcase_30 AC 63 ms
23,864 KB
testcase_31 AC 66 ms
21,876 KB
testcase_32 AC 62 ms
21,724 KB
testcase_33 AC 63 ms
21,712 KB
testcase_34 AC 84 ms
23,856 KB
testcase_35 AC 229 ms
53,472 KB
testcase_36 AC 212 ms
54,032 KB
testcase_37 AC 61 ms
23,752 KB
testcase_38 AC 225 ms
51,268 KB
testcase_39 AC 122 ms
37,988 KB
testcase_40 AC 147 ms
44,888 KB
testcase_41 AC 228 ms
55,296 KB
testcase_42 AC 226 ms
53,152 KB
testcase_43 AC 160 ms
43,992 KB
testcase_44 AC 90 ms
24,768 KB
testcase_45 AC 229 ms
55,304 KB
testcase_46 AC 130 ms
41,044 KB
testcase_47 AC 233 ms
53,380 KB
testcase_48 AC 183 ms
47,628 KB
testcase_49 AC 225 ms
55,264 KB
testcase_50 AC 62 ms
21,804 KB
testcase_51 AC 148 ms
45,400 KB
testcase_52 AC 212 ms
53,088 KB
testcase_53 AC 175 ms
43,372 KB
testcase_54 AC 243 ms
55,336 KB
testcase_55 AC 202 ms
51,784 KB
testcase_56 AC 203 ms
53,788 KB
testcase_57 AC 185 ms
49,172 KB
testcase_58 AC 100 ms
30,336 KB
testcase_59 AC 61 ms
21,752 KB
testcase_60 AC 183 ms
46,176 KB
testcase_61 AC 65 ms
21,700 KB
testcase_62 AC 134 ms
41,780 KB
testcase_63 AC 237 ms
53,392 KB
testcase_64 AC 203 ms
51,852 KB
testcase_65 AC 71 ms
22,028 KB
testcase_66 AC 116 ms
36,828 KB
testcase_67 AC 124 ms
36,972 KB
testcase_68 AC 121 ms
36,920 KB
testcase_69 AC 62 ms
21,828 KB
testcase_70 AC 131 ms
39,180 KB
testcase_71 AC 235 ms
55,416 KB
testcase_72 AC 234 ms
53,268 KB
testcase_73 AC 237 ms
55,452 KB
testcase_74 AC 233 ms
53,412 KB
testcase_75 AC 232 ms
51,192 KB
testcase_76 AC 234 ms
57,416 KB
testcase_77 AC 235 ms
53,404 KB
testcase_78 AC 62 ms
23,892 KB
testcase_79 AC 64 ms
23,748 KB
testcase_80 AC 235 ms
55,296 KB
testcase_81 AC 235 ms
53,260 KB
testcase_82 AC 235 ms
55,536 KB
testcase_83 AC 205 ms
49,864 KB
testcase_84 AC 153 ms
32,536 KB
testcase_85 AC 280 ms
43,192 KB
testcase_86 AC 206 ms
39,152 KB
testcase_87 AC 187 ms
36,056 KB
testcase_88 AC 80 ms
28,192 KB
testcase_89 AC 78 ms
24,540 KB
testcase_90 AC 328 ms
45,056 KB
testcase_91 AC 99 ms
30,008 KB
testcase_92 AC 85 ms
26,576 KB
testcase_93 AC 266 ms
44,456 KB
testcase_94 AC 189 ms
38,500 KB
testcase_95 AC 160 ms
34,032 KB
testcase_96 AC 139 ms
33,432 KB
testcase_97 AC 82 ms
28,540 KB
testcase_98 AC 314 ms
48,004 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);
		var yf = ToBoolN(y);

		for (int i = n - 1; i >= 0; i--)
		{
			var af = ToBool(a[i]);

			if (Matches(af, yf))
			{
				p.Push(3);
				while (p.Count < n) p.Push(1);
				return string.Join(" ", p);
			}
			{
				var ok = true;
				var t = new bool?[60];

				for (int f = 0; f < 60; f++)
				{
					if (yf[f] == null) continue;
					if (af[f]) t[f] = yf[f];
					else if (yf[f] == true) { ok = false; break; }
				}
				if (ok)
				{
					p.Push(1);
					yf = t;
					continue;
				}
			}
			{
				var ok = true;
				var t = new bool?[60];

				for (int f = 0; f < 60; f++)
				{
					if (yf[f] == null) continue;
					if (!af[f]) t[f] = yf[f];
					else if (yf[f] == false) { ok = false; break; }
				}
				if (ok)
				{
					p.Push(2);
					yf = t;
					continue;
				}
			}
			return -1;
		}

		if (!Matches(xf, yf)) return -1;
		return string.Join(" ", p);
	}
}
0