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

21119번 - Belarusian State University 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB414480.000%

문제

Being a student of Belarusian State University (BSU) is an earnest reason for pride. While studying the Theory of Algorithms course, you are obliged to solve many challenging problems before you are admitted to the final exam. Here is one of these problems.

You are given a positive integer $n$ and 4ドルn$ integers $c(i, j, k)$ which can be equal to 0ドル$ or 1ドル$ (0ドル \le i < n,ドル $j \in \left\{0, 1\right\},ドル $k \in \left\{0, 1\right\}$).

Consider two integers $x$ and $y$ between 0ドル$ and 2ドル^n - 1,ドル inclusively. Let $x = \sum\limits_{i = 0}^{n - 1}{x_i\cdot 2^i}$ and $y = \sum\limits_{i = 0}^{n - 1}{y_i \cdot 2^i}$ be their binary representations ($x_i, y_j \in \left\{0, 1\right\}$). Define $f(x, y) = \sum\limits_{i = 0}^{n - 1}{c(i, x_i, y_i)\cdot 2^i}$. Clearly, $f(x, y)$ is also an integer between 0ドル$ and 2ドル^n - 1$.

Given two multisets $A$ and $B,ドル find the multiset of values $f(a, b)$ over all pairs $(a, b),ドル where $a \in A,ドル $b \in B$.

입력

The first line contains an integer $n$ (1ドル \leq n \leq 18$).

The second line contains $n$ binary strings of 4ドル$ digits. The $i$-th string consists of the values of $c(i - 1, 0, 0),ドル $c(i - 1, 0, 1),ドル $c(i - 1, 1, 0),ドル $c(i - 1, 1, 1)$ in this particular order.

The next two lines describe multisets $A$ and $B,ドル respectively. The description of a multiset consists of 2ドル^n$ integers $q_0, q_1, \ldots, q_{2^n - 1}$ denoting the quantities of the numbers 0,ドル 1, \ldots, 2^n - 1$ in the multiset ($q_i \ge 0,ドル $\sum q_i \leq 10^9$). There are no other numbers in the multisets.

출력

Print 2ドル^n$ integers in a single line, the quantities of the numbers 0,ドル 1, \ldots, 2^n - 1$ in the resulting multiset.

제한

예제 입력 1

3
0111 0110 0001
0 0 0 0 0 1 0 0
0 0 0 0 0 0 1 0

예제 출력 1

0 0 0 0 0 0 0 1

예제 입력 2

2
1100 1101
2 0 2 1
2 0 2 1

예제 출력 2

2 4 3 16

예제 입력 3

1
0000
142857142 857142857
998244353 1755646

예제 출력 3

999999998000000001 0

힌트

In the first example, you are given 5ドル$ and 6ドル$. For $x_i, y_i \in \left\{0, 1\right\},ドル we have $$f(x_0 + 2x_1 + 4x_2, y_0 + 2y_1 + 4y_2) = (x_0 \text{ OR } y_0) + 2 \cdot (x_1 \text{ XOR } y_1) + 4 \cdot (x_2 \text{ AND } y_2).$$ Thus, the only number in the resulting multiset is 7ドル$.

출처

Camp > Petrozavodsk Programming Camp > Winter 2021 > Day 8: Belarusian SU Contest, Yandex Cup, Grand Prix of Belarud A번

Contest > Open Cup > 2020/2021 Season > Stage 12: Grand Prix of Belarus A번

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

출처

대학교 대회

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

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