結果

問題 No.1304 あなたは基本が何か知っていますか?私は知っています.
ユーザー さかぽんさかぽん
提出日時 2021-02-06 18:39:33
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 670 ms / 2,000 ms
コード長 2,136 bytes
コンパイル時間 2,720 ms
コンパイル使用メモリ 109,360 KB
実行使用メモリ 112,224 KB
最終ジャッジ日時 2023-09-03 04:16:00
合計ジャッジ時間 66,641 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 612 ms
52,196 KB
testcase_01 AC 614 ms
95,024 KB
testcase_02 AC 588 ms
54,208 KB
testcase_03 AC 622 ms
101,732 KB
testcase_04 AC 670 ms
55,236 KB
testcase_05 AC 638 ms
98,156 KB
testcase_06 AC 611 ms
53,108 KB
testcase_07 AC 641 ms
112,224 KB
testcase_08 AC 624 ms
53,616 KB
testcase_09 AC 644 ms
98,188 KB
testcase_10 AC 628 ms
56,192 KB
testcase_11 AC 638 ms
98,672 KB
testcase_12 AC 647 ms
55,596 KB
testcase_13 AC 630 ms
96,436 KB
testcase_14 AC 645 ms
55,656 KB
testcase_15 AC 632 ms
96,284 KB
testcase_16 AC 650 ms
55,668 KB
testcase_17 AC 641 ms
96,796 KB
testcase_18 AC 645 ms
55,600 KB
testcase_19 AC 635 ms
50,024 KB
testcase_20 AC 574 ms
49,760 KB
testcase_21 AC 588 ms
49,268 KB
testcase_22 AC 653 ms
51,368 KB
testcase_23 AC 654 ms
49,308 KB
testcase_24 AC 642 ms
49,132 KB
testcase_25 AC 629 ms
47,232 KB
testcase_26 AC 623 ms
49,188 KB
testcase_27 AC 638 ms
49,144 KB
testcase_28 AC 626 ms
49,248 KB
testcase_29 AC 635 ms
51,288 KB
testcase_30 AC 620 ms
47,804 KB
testcase_31 AC 622 ms
51,268 KB
testcase_32 AC 646 ms
49,232 KB
testcase_33 AC 627 ms
53,272 KB
testcase_34 AC 644 ms
47,184 KB
testcase_35 AC 618 ms
49,220 KB
testcase_36 AC 624 ms
51,272 KB
testcase_37 AC 640 ms
51,276 KB
testcase_38 AC 592 ms
51,276 KB
testcase_39 AC 582 ms
49,780 KB
testcase_40 AC 648 ms
49,172 KB
testcase_41 AC 651 ms
46,444 KB
testcase_42 AC 642 ms
49,144 KB
testcase_43 AC 638 ms
47,140 KB
testcase_44 AC 637 ms
49,236 KB
04_evil_A_01 RE -
04_evil_A_02 RE -
04_evil_A_03 RE -
04_evil_A_04 RE -
04_evil_A_05 RE -
04_evil_A_06 RE -
04_evil_A_07 RE -
04_evil_A_08 RE -
04_evil_A_09 RE -
04_evil_A_10 RE -
05_evil_B_01 TLE -
05_evil_B_02 TLE -
05_evil_B_03 TLE -
05_evil_B_04 TLE -
05_evil_B_05 TLE -
05_evil_B_06 TLE -
05_evil_B_07 TLE -
05_evil_B_08 TLE -
05_evil_B_09 TLE -
05_evil_B_10 TLE -
06_evil_C_01 RE -
06_evil_C_02 RE -
06_evil_C_03 RE -
06_evil_C_04 RE -
06_evil_C_05 RE -
06_evil_C_06 RE -
06_evil_C_07 RE -
06_evil_C_08 RE -
06_evil_C_09 RE -
06_evil_C_10 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Linq;

class A
{
	const long M = 998244353;
	const long MHalf = (M + 1) / 2;
	static int[] Read() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
	static (int, int, int, int) Read4() { var a = Read(); return (a[0], a[1], a[2], a[3]); }
	static void Main()
	{
		var (n, k, x, y) = Read4();
		var a = Read();

		a = a.Distinct().ToArray();
		k = a.Length;

		var c = NewArray2<long>(1 << 10, 1 << 10);
		var xors = new long[1 << 10];
		var rn1 = Enumerable.Range(0, n / 2 - 1).ToArray();

		Power(a, n / 2, p =>
		{
			if (rn1.Any(i => p[i] == p[i + 1])) return;
			var xor = p.Aggregate((x, y) => x ^ y);
			c[p[0]][xor]++;
			xors[xor]++;
		});

		var r = 0L;
		for (int u = 0; u < 1 << 10; u++)
			for (int v = 0; v < 1 << 10; v++)
			{
				if ((u ^ v) < x || y < (u ^ v)) continue;
				r += xors[u] * xors[v];
				r %= M;
			}

		for (int i = 0; i < 1 << 10; i++)
		{
			var c2 = (long[])c[i].Clone();
			c2 = Convolution(c2, c[i]);
			r -= c2[x..(y + 1)].Sum();
			r = MInt(r);
		}
		Console.WriteLine(r);
	}

	static T[][] NewArray2<T>(int n1, int n2, T v = default) => Array.ConvertAll(new bool[n1], _ => Array.ConvertAll(new bool[n2], __ => v));
	static long MInt(long x) => (x %= M) < 0 ? x + M : x;

	static void Power<T>(T[] values, int r, Action<T[]> action)
	{
		var n = values.Length;
		var p = new T[r];

		if (r > 0) Dfs(0);
		else action(p);

		void Dfs(int i)
		{
			var i2 = i + 1;
			for (int j = 0; j < n; ++j)
			{
				p[i] = values[j];

				if (i2 < r) Dfs(i2);
				else action(p);
			}
		}
	}

	static void Fwt(long[] c, bool inverse = false)
	{
		var n = c.Length;
		for (int i = 1; i < n; i <<= 1)
		{
			for (int j = 0; j < n; j++)
			{
				if ((j & i) != 0) continue;
				var x = c[j];
				var y = c[j | i];

				if (inverse)
				{
					c[j] = MInt((x + y) * MHalf);
					c[j | i] = MInt((x - y) * MHalf);
				}
				else
				{
					c[j] = MInt(x + y);
					c[j | i] = MInt(x - y);
				}
			}
		}
	}

	public static long[] Convolution(long[] a, long[] b)
	{
		Fwt(a);
		Fwt(b);
		for (int i = 0; i < a.Length; ++i) a[i] = a[i] * b[i] % M;
		Fwt(a, true);
		return a;
	}
}
0