QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#523158 | #866. Display of Springs | zjwwjhy | WA | 1ms | 3644kb | C++14 | 3.9kb | 2024-08-17 21:30:59 | 2024-08-17 21:30:59 |
Judging History
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;
// k[0]=3,k[1]=2,k[2]=1;
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;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3644kb
input:
3 SECOND SECOND FIRST
output:
? 0 1 1 ? 2 1 1 ? 2 0 1 1 2 0 ? 1 2 100000
result:
wrong answer Invalid input: invalid query token