結果

問題 No.1304 あなたは基本が何か知っていますか?私は知っています.
ユーザー さかぽん
提出日時 2021-02-06 16:53:42
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 1,144 bytes
コンパイル時間 1,651 ms
コンパイル使用メモリ 116,176 KB
実行使用メモリ 28,264 KB
最終ジャッジ日時 2025-06-22 03:06:41
合計ジャッジ時間 8,239 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 45 RE * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
	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 dp = NewArray2<long>(n + 1, 1 << 10);
		//dp[0][0] = 1;
		foreach (var v in a)
			dp[1][v] = 1;
		for (int i = 0; i < k; i++)
		{
			for (int j = i + 1; j < k; j++)
			{
				dp[2][a[i] ^ a[j]] += 2;
			}
		}

		for (int i = 2; i < n; i++)
		{
			for (int j = 0; j < 1 << 10; j++)
			{
				dp[i + 1][j] -= dp[i - 1][j] * (k - 1);
				dp[i + 1][j] = MInt(dp[i + 1][j]);
				if (dp[i][j] == 0) continue;
				foreach (var v in a)
				{
					var nv = j ^ v;
					dp[i + 1][nv] += dp[i][j] ;
					dp[i + 1][nv] %= M;
				}
			}
		}

		Console.WriteLine(dp[n][x..(y + 1)].Sum() % M);
	}

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