結果

問題 No.1304 あなたは基本が何か知っていますか?私は知っています.
ユーザー さかぽんさかぽん
提出日時 2021-02-07 00:12:35
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 662 ms / 2,000 ms
コード長 2,524 bytes
コンパイル時間 2,645 ms
コンパイル使用メモリ 108,340 KB
実行使用メモリ 73,668 KB
最終ジャッジ日時 2023-09-03 04:17:23
合計ジャッジ時間 65,962 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 601 ms
64,908 KB
testcase_01 AC 626 ms
67,576 KB
testcase_02 AC 581 ms
64,828 KB
testcase_03 AC 619 ms
69,076 KB
testcase_04 AC 654 ms
65,004 KB
testcase_05 AC 631 ms
70,964 KB
testcase_06 AC 601 ms
68,976 KB
testcase_07 AC 624 ms
73,668 KB
testcase_08 AC 621 ms
71,024 KB
testcase_09 AC 643 ms
68,916 KB
testcase_10 AC 637 ms
66,952 KB
testcase_11 AC 624 ms
66,948 KB
testcase_12 AC 647 ms
68,964 KB
testcase_13 AC 630 ms
67,536 KB
testcase_14 AC 635 ms
68,980 KB
testcase_15 AC 639 ms
69,784 KB
testcase_16 AC 662 ms
68,984 KB
testcase_17 AC 645 ms
71,576 KB
testcase_18 AC 644 ms
69,044 KB
testcase_19 AC 661 ms
60,596 KB
testcase_20 AC 589 ms
60,308 KB
testcase_21 AC 589 ms
64,428 KB
testcase_22 AC 658 ms
64,648 KB
testcase_23 AC 650 ms
64,556 KB
testcase_24 AC 656 ms
62,684 KB
testcase_25 AC 634 ms
60,404 KB
testcase_26 AC 633 ms
64,460 KB
testcase_27 AC 641 ms
62,564 KB
testcase_28 AC 633 ms
60,588 KB
testcase_29 AC 629 ms
66,540 KB
testcase_30 AC 605 ms
60,484 KB
testcase_31 AC 617 ms
64,536 KB
testcase_32 AC 633 ms
62,432 KB
testcase_33 AC 618 ms
64,496 KB
testcase_34 AC 625 ms
60,352 KB
testcase_35 AC 615 ms
64,412 KB
testcase_36 AC 621 ms
62,420 KB
testcase_37 AC 630 ms
60,492 KB
testcase_38 AC 578 ms
62,484 KB
testcase_39 AC 562 ms
62,536 KB
testcase_40 AC 638 ms
64,508 KB
testcase_41 AC 636 ms
60,480 KB
testcase_42 AC 630 ms
64,468 KB
testcase_43 AC 618 ms
60,384 KB
testcase_44 AC 624 ms
64,452 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
{
	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 = Hadamard.Convolution(c[i], c[i]);
			r -= c2[x..(y + 1)].Sum();
			r = MInt(r);
		}
		Console.WriteLine(r);
	}

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

	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);
			}
		}
	}
}

public static class Hadamard
{
	const long M = 998244353;
	static long MInt(long x) => (x %= M) < 0 ? x + M : x;
	static long MPow(long b, long i)
	{
		long r = 1;
		for (; i != 0; b = b * b % M, i >>= 1) if ((i & 1) != 0) r = r * b % M;
		return r;
	}
	static long MInv(long x) => MPow(x, M - 2);

	static void FwtInternal(long[] c)
	{
		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];
				c[j] = MInt(x + y);
				c[j | i] = MInt(x - y);
			}
	}

	// n: Power of 2
	// XOR
	public static long[] Fwt(long[] c, bool inverse = false)
	{
		var n = c.Length;
		var nInv = MInv(n);
		var r = new long[n];
		c.CopyTo(r, 0);
		FwtInternal(r);
		if (inverse) for (int i = 0; i < n; ++i) r[i] = r[i] * nInv % M;
		return r;
	}

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