听取“WA”声一片
查看原帖
听取“WA”声一片
1624467
wu_ming_ren_shi_楼主2025/8/4 21:56

这道题不会,有大佬帮忙看一下。

代码如下

#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,k,g,l=1,r=1e9;
    scanf("%d %d %d %d %d", &a, &b, &c, &k, &g);
    auto get=[](int arr,int pos){
        cout<<"1 "<<arr<<" "<<pos<<"\n";
        cout.flush();
        int x;
        cin>>x;
        return x;
    };
    if(a)
        r=max(r,get(1,a));
    if(b)
        r=max(r,get(2,b));
    if(c)
        r=max(r,get(3,c));
    while(l<r) {
        int m=l+(r-l)/2,cnt=0;
        auto count=[&](int arr,int sz){
            int L=1,R=sz,res=0;
            while(L<=R) {
                int M=(L+R)/2,v=get(arr,M);
                if(v<=m)
                    res=M,L=M+1;
                else
                    R=M-1;
            }
            return res;
        };
        if(a)
            cnt+=count(1,a);
        if(b)
            cnt+=count(2,b);
        if(c)
            cnt+=count(3,c);
        if(cnt<k)
            l=m+1;
        else
            r=m;
    }
    cout<<"2 "<<l<<endl;
    cout.flush();
    return 0;
}

帮忙看一下,帮助必关。

2025/8/4 21:56
加载中...