結果
問題 | No.1304 あなたは基本が何か知っていますか?私は知っています. |
ユーザー |
|
提出日時 | 2021-02-06 18:39:33 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 619 ms / 2,000 ms |
コード長 | 2,136 bytes |
コンパイル時間 | 1,014 ms |
コンパイル使用メモリ | 114,688 KB |
実行使用メモリ | 118,716 KB |
最終ジャッジ日時 | 2024-06-12 17:24:50 |
合計ジャッジ時間 | 60,508 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 44 RE * 20 TLE * 10 |
コンパイルメッセージ
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;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;}}