QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#211433 | #7407. Program Optimization | SolitaryDream# | AC ✓ | 300ms | 6284kb | C++17 | 1.2kb | 2023-10-12 16:20:28 | 2023-10-12 16:20:28 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1e3 + 7;
int n, q, k, s;
int pre[N], suf[N], a[N];
int query_mex(const int *a, int l, int r) {
return min(pre[l - 1], suf[r + 1]);
}
int simulate(int n, int *a, int q, int k, int s) {
std::mt19937 gen;
gen.seed(s);
int last = 0;
pre[0] = n;
for(int i = 1; i <= n; i += 1)
pre[i] = min(pre[i - 1], a[i]);
suf[n + 1] = n;
for(int i = n; i >= 1; i -= 1)
suf[i] = min(suf[i + 1], a[i]);
while (q--) {
int op = gen() % k;
int i = (gen() + last) % n;
i += 1;
if (!op && i > 1) {
std::swap(a[i - 1], a[i]);
for(int j = i - 1; j <= i; j += 1)
pre[j] = min(pre[j - 1], a[j]);
for(int j = i; j >= i - 1; j -= 1)
suf[j] = min(suf[j + 1], a[j]);
} else {
int j = gen() % n;
j += 1;
last ^= query_mex(a, std::min(i, j), std::max(i, j));
}
}
return last;
}
int main() {
scanf("%d%d%d%d", &n, &q, &k, &s);
for(int i = 1; i <= n; i += 1)
scanf("%d", &a[i]);
printf("%d\n", simulate(n, a, q, k, s));
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3844kb
input:
3 5 1 0 0 1 2
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 226ms
memory: 6196kb
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:
106138
result:
ok 1 number(s): "106138"
Test #3:
score: 0
Accepted
time: 300ms
memory: 6200kb
input:
200000 10000000 2 841507843 199999 199998 199997 199996 199995 199994 199993 199992 199991 199990 199989 199988 199987 199986 199985 199984 199983 199982 199981 199980 199979 199978 199977 199976 199975 199974 199973 199972 199971 199970 199969 199968 199967 199966 199965 199964 199963 199962 199961...
output:
218754
result:
ok 1 number(s): "218754"
Test #4:
score: 0
Accepted
time: 282ms
memory: 6280kb
input:
200000 10000000 5 78312093 199986 199976 199970 199943 199942 199931 199916 199909 199908 199907 199894 199882 199870 199869 199852 199849 199848 199833 199821 199805 199800 199795 199771 199755 199753 199739 199738 199736 199734 199728 199720 199715 199712 199705 199699 199697 199695 199694 199685 ...
output:
236570
result:
ok 1 number(s): "236570"
Test #5:
score: 0
Accepted
time: 275ms
memory: 6280kb
input:
200000 10000000 10 603298734 199999 199996 199995 199989 199985 199984 199983 199979 199977 199971 199969 199967 199965 199964 199959 199955 199950 199949 199948 199945 199944 199943 199942 199935 199933 199932 199928 199927 199926 199925 199920 199919 199917 199916 199915 199912 199909 199908 19990...
output:
87050
result:
ok 1 number(s): "87050"
Test #6:
score: 0
Accepted
time: 250ms
memory: 6264kb
input:
200000 10000000 100 356800522 199999 199998 199997 199996 199994 199993 199992 199991 199990 199988 199987 199986 199985 199984 199983 199982 199981 199980 199979 199978 199977 199976 199975 199974 199973 199972 199971 199969 199967 199966 199965 199964 199963 199962 199961 199960 199959 199958 1999...
output:
172112
result:
ok 1 number(s): "172112"
Test #7:
score: 0
Accepted
time: 245ms
memory: 6276kb
input:
200000 10000000 1000 670477491 199999 199998 199996 199994 199992 199991 199990 199989 199987 199985 199983 199981 199979 199978 199977 199975 199974 199972 199971 199970 199969 199965 199964 199962 199960 199959 199957 199956 199954 199953 199950 199949 199945 199944 199943 199940 199939 199938 199...
output:
205440
result:
ok 1 number(s): "205440"
Test #8:
score: 0
Accepted
time: 250ms
memory: 6280kb
input:
200000 10000000 10000 507623558 199998 199997 199996 199995 199994 199993 199991 199988 199986 199985 199984 199983 199981 199980 199978 199976 199974 199973 199972 199971 199970 199969 199968 199967 199966 199964 199963 199962 199961 199955 199954 199953 199952 199951 199950 199949 199948 199947 19...
output:
184512
result:
ok 1 number(s): "184512"
Test #9:
score: 0
Accepted
time: 249ms
memory: 6144kb
input:
200000 10000000 100000 886075807 199995 199992 199990 199980 199978 199975 199973 199972 199969 199961 199956 199951 199946 199944 199942 199940 199935 199934 199928 199927 199925 199912 199911 199907 199906 199905 199900 199899 199896 199894 199887 199884 199880 199878 199877 199874 199872 199871 1...
output:
36720
result:
ok 1 number(s): "36720"
Test #10:
score: 0
Accepted
time: 249ms
memory: 6284kb
input:
200000 10000000 1000000 978245484 199999 199998 199996 199995 199993 199992 199991 199990 199989 199988 199987 199984 199983 199982 199980 199977 199976 199975 199973 199972 199971 199970 199969 199968 199965 199964 199961 199960 199959 199958 199957 199955 199954 199953 199952 199951 199949 199947 ...
output:
260925
result:
ok 1 number(s): "260925"
Extra Test:
score: 0
Extra Test Passed