問題一覧 > 通常問題

No.1958 Bit Game

レベル : / AI推定難易度 : 1350 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 111
作問者 : PCTprobability / テスター : 👑 tute7627
お気に入りにしたユーザー ProblemId : 7829 / 自分の提出
問題文最終更新日: 2022-05-27 21:23:59
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 345 (順位表) の他の問題:

Problem Statement

You are given integer sequences $A=(A_1,A_2,\dots,A_X),B=(B_1,B_2,\dots,B_Y)$.

Initially, there is an integer $P=0$. PCT-kun and tute-san repeat the following operation $N$ times.

  • First, PCT-kun chooses $1$ element from $A$ uniformly at random. Let $Q$ be the chosen element, and replace $P$ with $P\ \mathrm{or}\ Q$.
  • Next, tute-san chooses $1$ element from $B$ uniformly at random. Let $R$ be the chosen element, and replace $P$ with $P\ \mathrm{and}\ R$.

There are $(XY)^N$ possible ways to perform the $N$ operations. Over all of them, find the sum of the values of $P$ at the end of the operations, $\bmod 998244353$.

Here, $\mathrm{or}$ in the statement denotes bitwise OR, and $\mathrm{and}$ denotes bitwise AND.

Input

$N\ X\ Y$
$A_1\ A_2\ \dots\ A_{X}$
$B_1\ B_2\ \dots\ B_{Y}$

  • All inputs are integers.
  • $1 \le N \le 2 \times 10^5$
  • $1 \le X,Y \le 2^{18}$
  • $0 \le A_i,B_j < 2^{18}$

Output

Output the answer on $1$ line.

Sample

Sample 1
Input
1 1 2
1
2 3
Output
1

The operation is performed only $1$ time. If PCT-kun chooses $1$ and tute-kun chooses $2$, the value of $P$ at the end of the operations is $0$. If PCT-kun chooses $1$ and tute-kun chooses $3$, the value of $P$ at the end of the operations is $1$. Therefore, the answer is $0+1=1$.

Sample 2
Input
5 4 3
1 2 3 4
5 6 7
Output
1130844

Sample 3
Input
527 5 5
0 1 2 3 4
5 6 7 8 9
Output
248270434

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。