QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#523130#866. Display of SpringszjwwjhyTL 0ms0kbC++144.1kb2024-08-17 20:47:502024-08-17 20:47:50

Judging History

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

  • [2024-08-17 20:47:50]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-08-17 20:47:50]
  • 提交

answer

#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define endl '\n'
using namespace std;
using ll=long long;
using db=double;
using pii=pair<int,int>;
const int inf=0x3f3f3f3f;
const int mod=998244353;
const int N=2e5+10,M=5e3+10;
int n;
int id[550];
double nl[550],k[550];
int na[550];
int nid[550],num[550],tot=-1;
string s;
void Sort(int l,int r){
    if(r==l) return ;
    int mid=id[rand()%(r-l+1)+l];
    // cout<<mid<<endl;
    int L=l-1,R=r+1;
    for(int i=l;i<=r;i++){
        if(id[i]==mid) continue;
        cout<<"? "<<id[i]<<" "<<mid<<" 1"<<endl;
        cin>>s;

        // if(nl[id[i]]<nl[mid]) s="FIRST";
        // else if(nl[id[i]]==nl[mid]) s="EQUAL";
        // else s="SECOND";

        if(s=="FIRST") na[++L]=id[i];
        else na[--R]=id[i];
    }
    for(int i=l;i<=r;i++){
        id[i]=na[i];
    }
    id[L+1]=mid;
    // cout<<l<<" "<<L<<" "<<R<<" "<<r<<endl;
    // for(int i=l;i<=r;i++){
    //     cout<<id[i]<<" ";
    // }cout<<endl;
    if(L>=l) Sort(l,L);
    if(R<=r) Sort(R,r);
}
int bsearch(int i,int j,int L,int R){
    int l=L,r=R,mid;
    while(l<r){
        mid=l+r>>1;
        cout<<"? "<<i<<" "<<j<<" "<<mid<<endl;
        // cout<<"!! "<<nl[i]-mid/k[i]<<" "<<nl[j]-mid/k[j]<<endl;
        cin>>s;

        // if(nl[i]-mid/k[i]<nl[j]-mid/k[j]) s="FIRST";
        // else if(nl[i]-mid/k[i]==nl[j]-mid/k[j]) s="EQUAL";
        // else s="SECOND";
        
        if(s=="FIRST") l=mid+1;
        else r=mid;
    }
    return l;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    srand(time(NULL));
    cin>>n;
    // nl[0]=100,nl[1]=50,nl[2]=52;
    // for(int i=0;i<n;i++){
    //     // nl[i]=rand();
    //     cout<<nl[i]<<" ";
    // }cout<<endl;
    // k[0]=3,k[1]=2,k[2]=1;
    // for(int i=0;i<n;i++){
    //     // k[i]=rand();
    //     cout<<k[i]<<" ";
    // }cout<<endl;
    for(int i=0;i<n;i++) id[i]=i;
    Sort(0,n-1);
    // for(int i=0;i<n;i++){
    //     cout<<id[i]<<" ";
    // }cout<<endl;
    int w=1;
    for(int i=0;i<n;i++){
        if(i==0) nid[++tot]=id[i],num[tot]=1;
        else{
            cout<<"? "<<nid[tot]<<" "<<id[i]<<" "<<100000<<endl;
            cin>>s;

            // cout<<"!! "<<nl[nid[tot]]-100000/k[nid[tot]]<<" "<<nl[id[i]]-100000/k[id[i]]<<endl;
            // if(nl[nid[tot]]-100000/k[nid[tot]]<nl[id[i]]-100000/k[id[i]]) s="FIRST";
            // else if(nl[nid[tot]]-100000/k[nid[tot]]==nl[id[i]]-100000/k[id[i]]) s="EQUAL";
            // else s="SECOND";

            if(s!="SECOND") continue;
            cout<<"? "<<nid[tot]<<" "<<id[i]<<" "<<w<<endl;
            cin>>s;

            // cout<<"!! "<<nl[nid[tot]]-w/k[nid[tot]]<<" "<<nl[id[i]]-w/k[id[i]]<<" "<<w<<endl;
            // if(nl[nid[tot]]-w/k[nid[tot]]<nl[id[i]]-w/k[id[i]]) s="FIRST";
            // else if(nl[nid[tot]]-w/k[nid[tot]]==nl[id[i]]-w/k[id[i]]) s="EQUAL";
            // else s="SECOND";

            while(s!="FIRST"){
                tot--;
                if(tot==-1) break;
                cout<<"? "<<nid[tot]<<" "<<id[i]<<" "<<w<<endl;
                cin>>s;
                w=num[tot];
                // cout<<"!! "<<nl[nid[tot]]-w/k[nid[tot]]<<" "<<nl[id[i]]-w/k[id[i]]<<" "<<w<<endl;
                // if(nl[nid[tot]]-w/k[nid[tot]]<nl[id[i]]-w/k[id[i]]) s="FIRST";
                // else if(nl[nid[tot]]-w/k[nid[tot]]==nl[id[i]]-w/k[id[i]]) s="EQUAL";
                // else s="SECOND";

            }
            nid[++tot]=id[i];
            if(tot==0){
                num[tot]=1;
            }
            else{
                num[tot]=bsearch(nid[tot-1],id[i],w,100000);
                // cout<<"______________"<<num[tot]<<endl;
            }
            w=num[tot];
        }
    }
    // for(int i=0;i<=tot;i++){
    //     cout<<i<<"->"<<nid[i]<<"="<<num[i]<<endl;
    // }
    cout<<"!"<<endl;
    while(cin>>s>>w){
        for(int i=0;i<=tot;i++){
            if(i==tot && w>=num[i] || w>=num[i] && w<num[i+1]){
                cout<<"! "<<nid[i]<<endl;
            }
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

3

output:


result: