結果
問題 | No.1304 あなたは基本が何か知っていますか?私は知っています. |
ユーザー |
|
提出日時 | 2021-02-06 17:07:37 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 42 ms / 2,000 ms |
コード長 | 1,100 bytes |
コンパイル時間 | 5,145 ms |
コンパイル使用メモリ | 115,264 KB |
実行使用メモリ | 27,880 KB |
最終ジャッジ日時 | 2024-06-12 17:23:15 |
合計ジャッジ時間 | 7,538 ms |
ジャッジサーバーID (参考情報) |
judge1 / 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.
ソースコード
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);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;}