QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#202914 | #7407. Program Optimization | Scarlett_boy | WA | 9ms | 4500kb | C++17 | 1.2kb | 2023-10-06 14:05:10 | 2023-10-06 14:05:11 |
Judging History
answer
#include<bits/stdc++.h>
#pragma GCC optimize(3)
typedef long long ll;
using namespace std;
const int N = 2e5 + 50;
const int mod = 1e9 + 7;
int a[N];
int vis[N];
int query_mex(int l, int r) {
for (int i = 0; i <= 2e5; i++) vis[i] = 0;
for (int i = l; i <= r; i++) vis[a[i]] = 1;
int p = 0;
while (vis[p]) p++;
return p;
}
int simulate(int n, 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(std::min(i, j), std::max(i, j));
}
}
return last;
}
int n, q, k, s;
void solve() {
cin >> n >> q >> k >> s;
for (int i = 0; i < n; i++) cin >> a[i];
cout << simulate(n, 1, k, s) << '\n';
}
int main() {
ios::sync_with_stdio(false), cin.tie(nullptr);
int _ = 1;
// cin >> _;
for (int o = 1; o <= _; o++) {
solve();
}
return 0;
}
/*
5
3 1 1 0
0 1 2
3 2 1 0
0 1 2
3 3 1 0
0 1 2
3 4 1 0
0 1 2
3 5 1 0
0 1 2
*/
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 4412kb
input:
3 5 1 0 0 1 2
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: -100
Wrong Answer
time: 9ms
memory: 4500kb
input:
200000 10000000 1 664250662 199997 199996 199994 199993 199992 199991 199990 199989 199988 199987 199986 199984 199983 199981 199979 199978 199977 199976 199975 199974 199973 199970 199969 199968 199966 199965 199964 199963 199962 199961 199960 199958 199957 199956 199955 199953 199952 199951 199948...
output:
0
result:
wrong answer 1st numbers differ - expected: '106138', found: '0'