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

23496번 - Program Optimization 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 256 MB247746.667%

문제

Consider the following C++ code:

#include <algorithm>
#include <random>
int query_mex(const int *a, int l, int r);
int simulate(int n, int *a, int q, int k, int s) {
 std::mt19937 gen;
 gen.seed(s);
 int last = 0;
 while (q--) {
 int op = gen() % k;
 int i = (gen() + last) % n;
 if (!op && i) {
 std::swap(a[i - 1], a[i]);
 } else {
 int j = gen() % n;
 last ^= query_mex(a, std::min(i, j), std::max(i, j));
 }
 }
 return last;
}

In the program, query_mex(a, l, r) returns the minimum non-negative integers which does not occur in $a_l, a_{l + 1}, \dots, a_{r}$.

Given the value of $n,ドル $a,ドル $q,ドル $k$ and $s,ドル find the returned value of the function.

입력

The first line contains four integers $n,ドル $q,ドル $k$ and $s$ (1ドル \leq n \leq 2\times 10^5,ドル 1ドル \leq q \leq 10^7,ドル 1ドル \leq k \leq 10^9,ドル 0ドル \leq s \leq 10^9$). The second line contains $n$ distinct integers $a_0, a_1, \dots, a_{n - 1}$ (0ドル \leq a_i < n$).

출력

Output an integer denoting the returned value.

제한

예제 입력 1

3 5 1 0
0 1 2

예제 출력 1

3

힌트

출처

Contest > Open Cup > 2019/2020 Season > Stage 18: Grand Prix of Bytedance J번

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

출처

대학교 대회

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

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