QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#855272#9989. Harmful Machine LearningAlencryenfoWA 93ms3624kbC++202.9kb2025-01-12 17:06:112025-01-12 17:06:12

Judging History

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

  • [2025-01-12 17:06:12]
  • 评测
  • 测评结果:WA
  • 用时:93ms
  • 内存:3624kb
  • [2025-01-12 17:06:11]
  • 提交

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=getmin(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: -100
Wrong Answer
time: 93ms
memory: 3624kb

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:

wrong answer 465th lines differ - expected: '1', found: '0'