QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#855274#9989. Harmful Machine LearningAlencryenfoWA 134ms3764kbC++202.9kb2025-01-12 17:07:182025-01-12 17:07:19

Judging History

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

  • [2025-01-12 17:07:19]
  • 评测
  • 测评结果:WA
  • 用时:134ms
  • 内存:3764kb
  • [2025-01-12 17:07:18]
  • 提交

answer

#include <algorithm>
#include <iostream>
#include<vector>
#include <cstdarg>
#include <climits>
#include <queue>
#include <ranges>
using namespace std;
int getmin(int num,...) {
    va_list parameter;
    va_start(parameter, num);
    int ansmin=INT_MAX;
    for(int i=0;i<num;i++) {
        int tmp=va_arg(parameter, int);
        ansmin=min(ansmin,tmp);
    }
    return ansmin;
}
int getmax(int num,...) {
    va_list parameter;
    va_start(parameter, num);
    int ansmax=INT_MIN;
    for(int i=0;i<num;i++) {
        int tmp=va_arg(parameter, int);
        ansmax=max(ansmax,tmp);
    }
    return ansmax;
}
int T,n,x;
int main() {
    cin>>T;
    while(T--) {
        cin>>n>>x;
        vector<int> arr(n+1);
        priority_queue<int,vector<int>,greater<>> otherArr;
        for(int i=1;i<=n;i++) {
            cin>>arr[i];
            if ((x!=n&&x!=1)&&(i>x+1||i<x-1))otherArr.push(arr[i]);
            if (x==1&&i>x+2)otherArr.push(arr[i]);
            if (x==n&&i<x-2)otherArr.push(arr[i]);
        }
        if(n==1) {
            cout<<arr[1]<<endl;
        }else if(n==2) {
            cout<<getmax(2,arr[1],arr[2])<<endl;
        }else if (n==3) {
            cout<<getmax(3,arr[1],arr[2],arr[3])<<endl;
        }else {
            if (x==n) {
                reverse(arr.begin()+1,arr.end());
                x=1;
            }
            if (x==1) {
                //计算第一种情况
                // int ans1=INT_MIN;
                // if (arr[1]<arr[2]) swap(arr[1],arr[2]);
                // if (arr[1]>otherArr.top())ans1=getmax(2,arr[2],otherArr.top());
                // else ans1=arr[1];
                //计算第二种情况
                int ans=INT_MIN;
                priority_queue<int,vector<int>,greater<>> otherArr1=otherArr;
                if (arr[1]<arr[2]) swap(arr[1],arr[2]);
                if (arr[1]>otherArr1.top()){
                    otherArr1.push(arr[1]);
                    arr[1]=otherArr1.top();
                    otherArr1.pop();
                }
                ans=getmax(2,arr[1],arr[2]);
                if (arr[2]<arr[3]) swap(arr[2],arr[3]);
                if (arr[2]>otherArr1.top()){
                    otherArr1.push(arr[2]);
                    arr[2]=otherArr1.top();
                    otherArr1.pop();
                }
                ans=getmax(4,arr[1],arr[2],arr[3],ans);
                cout<<ans<<endl;
            }else {
                int place=x-1,data=arr[x-1],ans=INT_MIN;
                for (int i=x;i<=x+1;i++) {
                    if (arr[i]>=data) place=i,data=arr[i];
                }
                if (arr[place]>otherArr.top()){
                    otherArr.push(arr[1]);
                    arr[place]=otherArr.top();
                    otherArr.pop();
                }
                ans=getmax(3,arr[x-1],arr[x],arr[x+1]);
                cout<<ans<<endl;
            }
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
3 2
1 2 3
13 4
1 1 4 5 1 4 1 9 1 9 8 1 0
4 2
1 10 100 1000
1 1
114514

output:

3
4
100
114514

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 63ms
memory: 3764kb

input:

100000
1 1
1
5 4
1 0 0 0 0
5 4
0 1 1 0 1
2 2
1 1
1 1
1
4 3
0 0 0 1
1 1
0
2 1
1 0
2 2
0 1
3 3
0 0 1
3 1
1 0 0
1 1
1
2 1
0 1
5 4
0 1 1 1 1
1 1
1
5 5
0 0 0 1 0
2 1
1 0
4 4
1 0 0 1
3 2
0 0 1
5 3
1 1 1 0 1
3 3
0 0 1
2 2
1 1
4 1
1 1 0 1
4 1
0 0 1 1
1 1
0
5 4
1 0 1 0 0
4 3
0 0 1 1
1 1
1
3 3
0 1 1
5 4
1 0 0...

output:

1
0
1
1
1
0
0
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
0
0
1
1
1
0
0
1
1
1
0
1
0
1
1
0
0
1
0
1
0
0
0
1
1
1
1
1
0
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
0
0
0
0
1
0
1
1
1
1
1
0
0
1
1
1
1
1
1
1
1
0
1
1
0
0
0
1
1
1
1
0
1
1
1
0
0
0
1
1
1
1
1
0
0
1
0
0
1
1
1
0
1
0
1
0
0
0
1
1
1
1
1
1
1
0
0
0
0
1
0
0
1
0
0
1
1
1
1
...

result:

ok 100000 lines

Test #3:

score: -100
Wrong Answer
time: 134ms
memory: 3540kb

input:

100000
2 2
59820207 376803742
3 2
208862368 319232484 27144855
4 3
773899181 465093098 722012192 436481034
2 1
780276037 871545470
1 1
710180001
1 1
420011585
3 1
385108264 307138942 241489653
5 4
737902242 315557098 600286836 883838302 938250085
2 2
806646512 330829636
4 3
856420721 973701499 43835...

output:

376803742
319232484
722012192
871545470
710180001
420011585
385108264
883838302
806646512
856420721
554247848
960484949
415586825
616215879
303945379
472961236
417431687
796718792
421695538
725220942
745175356
983721950
617752199
100888645
431107906
940001412
524096689
678058393
500133506
791526145
...

result:

wrong answer 228th lines differ - expected: '762591892', found: '702255285'