結果
問題 |
No.1304 あなたは基本が何か知っていますか?私は知っています.
|
ユーザー |
|
提出日時 | 2020-12-27 19:38:14 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,465 bytes |
コンパイル時間 | 4,246 ms |
コンパイル使用メモリ | 113,440 KB |
実行使用メモリ | 45,420 KB |
最終ジャッジ日時 | 2025-06-22 03:04:45 |
合計ジャッジ時間 | 5,670 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 1 TLE * 1 -- * 72 |
コンパイルメッセージ
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(); Array.Sort(a); k = a.Length; var c = NewArray2<long>(1 << 10, 1 << 10); var countsByXor = 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]++; countsByXor[xor]++; }); var r = 0L; for (int i = 0; i < 1 << 10; i++) for (int j = 0; j < 1 << 10; j++) { if ((i ^ j) < x || y < (i ^ j)) continue; r += countsByXor[i] * countsByXor[j]; r %= M; for (int a0 = 0; a0 < 1 << 10; a0++) { r -= c[a0][i] * c[a0][j]; r = (r + M) % M; } } 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 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); } } } }