結果

問題 No.1355 AND OR GAME
ユーザー さかぽんさかぽん
提出日時 2021-01-24 16:43:00
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 868 ms / 2,000 ms
コード長 1,806 bytes
コンパイル時間 5,460 ms
コンパイル使用メモリ 103,924 KB
実行使用メモリ 57,268 KB
最終ジャッジ日時 2023-08-30 23:53:32
合計ジャッジ時間 30,239 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
23,776 KB
testcase_01 AC 62 ms
23,692 KB
testcase_02 AC 71 ms
19,924 KB
testcase_03 AC 71 ms
21,972 KB
testcase_04 AC 71 ms
22,020 KB
testcase_05 AC 63 ms
23,652 KB
testcase_06 AC 72 ms
23,932 KB
testcase_07 AC 72 ms
21,880 KB
testcase_08 AC 71 ms
21,876 KB
testcase_09 AC 70 ms
21,764 KB
testcase_10 AC 63 ms
23,852 KB
testcase_11 AC 62 ms
21,772 KB
testcase_12 AC 64 ms
21,756 KB
testcase_13 AC 62 ms
21,668 KB
testcase_14 AC 62 ms
23,720 KB
testcase_15 AC 62 ms
21,636 KB
testcase_16 AC 64 ms
21,744 KB
testcase_17 AC 62 ms
21,780 KB
testcase_18 AC 63 ms
21,672 KB
testcase_19 AC 62 ms
25,736 KB
testcase_20 AC 63 ms
21,760 KB
testcase_21 AC 62 ms
21,624 KB
testcase_22 AC 62 ms
19,780 KB
testcase_23 AC 63 ms
23,824 KB
testcase_24 AC 61 ms
21,644 KB
testcase_25 AC 64 ms
23,640 KB
testcase_26 AC 63 ms
23,836 KB
testcase_27 AC 61 ms
21,824 KB
testcase_28 AC 63 ms
23,712 KB
testcase_29 AC 63 ms
23,648 KB
testcase_30 AC 63 ms
21,776 KB
testcase_31 AC 63 ms
23,804 KB
testcase_32 AC 63 ms
19,740 KB
testcase_33 AC 63 ms
21,816 KB
testcase_34 AC 84 ms
23,744 KB
testcase_35 AC 229 ms
53,252 KB
testcase_36 AC 216 ms
51,924 KB
testcase_37 AC 63 ms
21,712 KB
testcase_38 AC 234 ms
53,296 KB
testcase_39 AC 124 ms
39,888 KB
testcase_40 AC 150 ms
40,904 KB
testcase_41 AC 234 ms
55,228 KB
testcase_42 AC 228 ms
53,232 KB
testcase_43 AC 159 ms
43,920 KB
testcase_44 AC 92 ms
26,724 KB
testcase_45 AC 233 ms
55,216 KB
testcase_46 AC 132 ms
41,092 KB
testcase_47 AC 234 ms
51,172 KB
testcase_48 AC 190 ms
47,556 KB
testcase_49 AC 228 ms
55,232 KB
testcase_50 AC 62 ms
21,716 KB
testcase_51 AC 150 ms
43,220 KB
testcase_52 AC 213 ms
53,000 KB
testcase_53 AC 169 ms
47,368 KB
testcase_54 AC 236 ms
55,216 KB
testcase_55 AC 207 ms
51,692 KB
testcase_56 AC 203 ms
51,752 KB
testcase_57 AC 190 ms
49,212 KB
testcase_58 AC 99 ms
26,116 KB
testcase_59 AC 62 ms
21,776 KB
testcase_60 AC 181 ms
50,212 KB
testcase_61 AC 62 ms
21,736 KB
testcase_62 AC 131 ms
39,420 KB
testcase_63 AC 235 ms
53,248 KB
testcase_64 AC 205 ms
53,872 KB
testcase_65 AC 71 ms
23,904 KB
testcase_66 AC 114 ms
36,668 KB
testcase_67 AC 121 ms
34,780 KB
testcase_68 AC 120 ms
38,648 KB
testcase_69 AC 63 ms
21,580 KB
testcase_70 AC 130 ms
37,104 KB
testcase_71 AC 231 ms
55,336 KB
testcase_72 AC 234 ms
57,268 KB
testcase_73 AC 236 ms
55,384 KB
testcase_74 AC 236 ms
55,308 KB
testcase_75 AC 236 ms
55,192 KB
testcase_76 AC 234 ms
53,224 KB
testcase_77 AC 235 ms
53,260 KB
testcase_78 AC 60 ms
21,732 KB
testcase_79 AC 62 ms
21,644 KB
testcase_80 AC 233 ms
55,244 KB
testcase_81 AC 231 ms
55,308 KB
testcase_82 AC 227 ms
53,268 KB
testcase_83 AC 202 ms
51,700 KB
testcase_84 AC 318 ms
32,408 KB
testcase_85 AC 703 ms
41,060 KB
testcase_86 AC 454 ms
39,084 KB
testcase_87 AC 406 ms
37,956 KB
testcase_88 AC 99 ms
26,188 KB
testcase_89 AC 89 ms
24,376 KB
testcase_90 AC 868 ms
44,848 KB
testcase_91 AC 159 ms
30,020 KB
testcase_92 AC 108 ms
26,636 KB
testcase_93 AC 727 ms
44,232 KB
testcase_94 AC 452 ms
38,432 KB
testcase_95 AC 338 ms
35,896 KB
testcase_96 AC 281 ms
31,456 KB
testcase_97 AC 105 ms
28,480 KB
testcase_98 AC 856 ms
47,836 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 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 = ToBoolN(x);
		var yf = ToBoolN(y);

		for (int i = n - 1; i >= 0; i--)
		{
			var af = ToBoolN(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 (Match(af[f] & null, yf[f])) { }
					else if (Match(af[f] & true, yf[f])) t[f] = true;
					else if (Match(af[f] & false, yf[f])) t[f] = false;
					else { 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 (Match(af[f] | null, yf[f])) { }
					else if (Match(af[f] | true, yf[f])) t[f] = true;
					else if (Match(af[f] | false, yf[f])) t[f] = false;
					else { ok = false; break; }
				}
				if (ok)
				{
					p.Push(2);
					yf = t;
					continue;
				}
			}
			return -1;
		}

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