QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#601560#7407. Program Optimizationrotcar07AC ✓310ms6068kbC++20682b2024-09-30 07:35:332024-09-30 07:35:33

Judging History

你现在查看的是最新测评结果

  • [2024-09-30 07:35:33]
  • 评测
  • 测评结果:AC
  • 用时:310ms
  • 内存:6068kb
  • [2024-09-30 07:35:33]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,q,k,s;
constexpr int maxn=2e5+5;
int a[maxn],pre[maxn],suf[maxn];
int main(){
    cin>>n>>q>>k>>s;
    mt19937 gen(s);
    int lst=0;
    for(int i=1;i<=n;i++) cin>>a[i];
    pre[0]=suf[n+1]=n;
    for(int i=1;i<=n;i++) pre[i]=min(pre[i-1],a[i]);
    for(int i=n;i>=1;i--) suf[i]=min(suf[i+1],a[i]);
    while(q--){
        int op=gen()%k;
        int i=(gen()+lst)%n;
        if(!op&&i)swap(a[i],a[i+1]),pre[i]=min(pre[i-1],a[i]),suf[i+1]=min(suf[i+2],a[i+1]);
        else{
            int j=gen()%n;i++,j++;if(i>j) swap(i,j);
            lst^=min(pre[i-1],suf[j+1]);
        }
    }
    cout<<lst<<'\n';
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3736kb

input:

3 5 1 0
0 1 2

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 184ms
memory: 6068kb

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: 284ms
memory: 6052kb

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: 298ms
memory: 6064kb

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: 310ms
memory: 5852kb

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: 295ms
memory: 5916kb

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: 296ms
memory: 5992kb

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: 299ms
memory: 5980kb

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: 301ms
memory: 5912kb

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: 294ms
memory: 5896kb

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