Logo
(追記) (追記ここまで)

33334번 - Bitsets 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 2048 MB332100.000%

문제

Let us consider the following operations on bitsets of size $m$:

  • $c = a,円 \mathrm{ and },円 b$. Here, $c_i=1$ if both $a_i$ and $b_i$ are equal to 1ドル$. Otherwise, $c_i=0$.
  • $c = a,円 \mathrm{ or },円 b$. Here, $c_i=1$ if either $a_i$ or $b_i$ is equal to 1ドル$. Otherwise, $c_i=0$.
  • $c = a,円 \mathrm{ xor },円 b$. Here, $c_i=1$ if exactly one of $a_i$ and $b_i$ is equal to 1ドル$. Otherwise, $c_i=0$.
  • $c = \mathrm{ not },円 a$. Here, $c_i=1$ if $a_i$ is equal to 0ドル$. Otherwise, $c_i=0$.

You are given an array of bitsets $s_1, s_2, \ldots, s_n$. Write a program that can answer $k$ queries of the following form:

  1. Take two integers $\ell$ and $r$.
  2. Find bitset $t$ using the formula: $t = (s_\ell ,円\mathrm{ and },円 s_{\ell+1} ,円\mathrm{ and },円 \ldots ,円\mathrm{ and },円 s_r) ,円\mathrm{ xor },円 (\mathrm{ not },円 (s_\ell ,円\mathrm{ or },円 s_{\ell+1} ,円\mathrm{ or },円 \ldots ,円\mathrm{ or },円 s_r))$.
  3. Count the number of ones in bitset $t$: it is the answer.

입력

The first line contains two integers $n$ and $m$ (1ドル \leq n, m \leq 10^5$; $n \cdot m \leq 10^6$). The following $n$ lines describe the $n$ bitsets, where each line consists of $m$ characters 0ドル$ and 1ドル$ representing the bits of that bitset.

The next line of the input contains a single integer $k$ (1ドル \leq k \leq 2 \cdot 10^7$), which denotes the number of queries. The following line contains three integers $x,ドル $y,ドル and $z$ (1ドル \leq x, y, z \leq 10^9$).

The queries are generated using pseudo-random numbers, with input parameters $x,ドル $y,ドル and $z,ドル and a sequence $q_1, q_2, \ldots, q_{k - 1}$ of answers to the queries. Define two sequences $a$ and $b$ as follows:

  • $a_1 = 1$.
  • $b_1 = n$.
  • For $i > 1,ドル $a_i = (a_{i-1} \cdot x + q_{i-1} \cdot y + z) \bmod n + 1$.
  • For $i > 1,ドル $b_i = (b_{i-1} \cdot y + q_{i-1} \cdot z + x) \bmod n + 1$.

For each query $i,ドル the parameters $\ell$ and $r$ are defined as $\ell=\min(a_i, b_i)$ and $r=\max(a_i, b_i)$.

출력

Output a single integer: the sum of the answers for all queries.

제한

예제 입력 1

4 10
1010110101
0101111001
1101101101
1011010000
4
10 5 4

예제 출력 1

9

노트

The queries are listed below:

# $\ell$ $r$ answer
1 1ドル$ 4ドル$ 1ドル$
2 3ドル$ 4ドル$ 3ドル$
3 2ドル$ 4ドル$ 2ドル$
4 1ドル$ 3ドル$ 3ドル$

출처

Camp > Petrozavodsk Programming Camp > Summer 2023 > Day 2: Nyatl Contest 2023 B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /