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

23177번 - Or Machine 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 (추가 시간 없음) 1024 MB385816621.222%

문제

We are developing the Or Machine, a computer heavily optimized solely for one kind of operation: the \verb |= \ operator in C++'s term.

The Or Machine has $n$ registers, each containing a nonnegative integer less than 2ドル^8$. We label them $x_1, x_2, \cdots, x_n$. A program is represented by a list of $l$ operations. Each operation is represented by a pair of integers $(a, b),ドル meaning that the machine should update $x_a$ with the bitwise OR of $x_a$'s and $x_b$'s values.

The Or Machine takes a program, the initial values of the registers, and a positive integer $t$. When run, the program performs each operation in the program one by one. When the last operation is performed, it goes back to the first operation and repeats the process. The machine stops after performing exactly $t$ operations.

We want our machine to be much faster than general-purpose computers, and hardware optimization is probably not enough. Can you help us with some software optimization?

입력

The first line contains three integers, $n,ドル $l,ドル and $t\ (1 \leq n, l \leq 2^{18},ドル 1ドル \leq t \leq 10^{18})$. $l$ is the length of the program.

The program is given on the next $l$ lines. Each line contains two integers $a$ and $b\ (1 \leq a, b \leq n)$ representing the pair of registers that participate in the given operation.

The final line contains $n$ integers, the initial values of the registers $x_1, \cdots, x_n\ (0 \le x_i < 2^8)$.

출력

Output $n$ integers on a single line, the values of the registers $x_1, \cdots, x_n$ after $t$ operations.

제한

예제 입력 1

5 4 5
1 2
2 3
2 4
4 4
8 0 5 3 10

예제 출력 1

15 7 5 3 10

힌트

출처

University > KAIST > KAIST ICPC Mock Competition > 2021 KAIST 11th ICPC Mock Competition H번

Contest > Open Cup > 2021/2022 Season > Stage 4: Grand Prix of Korea H번

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

출처

대학교 대회

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

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