QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#523159 | #866. Display of Springs | zjwwjhy | WA | 42ms | 3768kb | C++14 | 3.9kb | 2024-08-17 21:33:13 | 2024-08-17 21:33:14 |
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: 100
Accepted
time: 1ms
memory: 3752kb
input:
3 SECOND SECOND FIRST SECOND FIRST SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND FIRST SECOND EQUAL FIRST QUESTION 2 QUESTION 6 FINISH
output:
? 0 1 1 ? 2 1 1 ? 2 0 1 ? 1 2 100000 ? 1 2 1 ? 1 2 50000 ? 1 2 25000 ? 1 2 12500 ? 1 2 6250 ? 1 2 3125 ? 1 2 1563 ? 1 2 782 ? 1 2 391 ? 1 2 196 ? 1 2 98 ? 1 2 49 ? 1 2 25 ? 1 2 13 ? 1 2 7 ? 1 2 4 ? 1 2 6 ? 1 2 5 ? 2 0 100000 ! ! 1 ! 2
result:
ok Correct answer
Test #2:
score: 0
Accepted
time: 0ms
memory: 3764kb
input:
6 EQUAL SECOND SECOND SECOND SECOND SECOND FIRST FIRST FIRST SECOND FIRST FIRST SECOND FIRST SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND EQUAL FIRST SECOND FIRST SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND ...
output:
? 0 1 1 ? 2 1 1 ? 3 1 1 ? 4 1 1 ? 5 1 1 ? 5 4 1 ? 3 4 1 ? 2 4 1 ? 0 4 1 ? 3 2 1 ? 0 2 1 ? 1 0 100000 ? 1 2 100000 ? 1 2 1 ? 1 2 50000 ? 1 2 25000 ? 1 2 12500 ? 1 2 6250 ? 1 2 3125 ? 1 2 1563 ? 1 2 782 ? 1 2 391 ? 1 2 196 ? 1 2 98 ? 1 2 49 ? 1 2 25 ? 1 2 13 ? 1 2 7 ? 1 2 4 ? 1 2 2 ? 1 2 1 ? 2 3 10000...
result:
ok Correct answer
Test #3:
score: 0
Accepted
time: 13ms
memory: 3680kb
input:
326 FIRST SECOND FIRST SECOND FIRST SECOND SECOND SECOND FIRST SECOND SECOND SECOND SECOND FIRST SECOND SECOND SECOND FIRST SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND FIRST FIRST FIRST SECOND SECOND FIRST SECOND FIRST SECOND FIRST SECOND SECOND SECOND ...
output:
? 0 77 1 ? 1 77 1 ? 2 77 1 ? 3 77 1 ? 4 77 1 ? 5 77 1 ? 6 77 1 ? 7 77 1 ? 8 77 1 ? 9 77 1 ? 10 77 1 ? 11 77 1 ? 12 77 1 ? 13 77 1 ? 14 77 1 ? 15 77 1 ? 16 77 1 ? 17 77 1 ? 18 77 1 ? 19 77 1 ? 20 77 1 ? 21 77 1 ? 22 77 1 ? 23 77 1 ? 24 77 1 ? 25 77 1 ? 26 77 1 ? 27 77 1 ? 28 77 1 ? 29 77 1 ? 30 77 1 ...
result:
ok Correct answer
Test #4:
score: 0
Accepted
time: 4ms
memory: 3676kb
input:
19 FIRST FIRST FIRST FIRST SECOND FIRST FIRST FIRST FIRST SECOND SECOND FIRST FIRST SECOND FIRST FIRST FIRST FIRST SECOND FIRST SECOND SECOND SECOND FIRST FIRST FIRST FIRST SECOND SECOND FIRST FIRST SECOND FIRST FIRST FIRST SECOND SECOND SECOND SECOND SECOND SECOND SECOND FIRST SECOND SECOND FIRST S...
output:
? 0 7 1 ? 1 7 1 ? 2 7 1 ? 3 7 1 ? 4 7 1 ? 5 7 1 ? 6 7 1 ? 8 7 1 ? 9 7 1 ? 10 7 1 ? 11 7 1 ? 12 7 1 ? 13 7 1 ? 14 7 1 ? 15 7 1 ? 16 7 1 ? 17 7 1 ? 18 7 1 ? 0 6 1 ? 1 6 1 ? 2 6 1 ? 3 6 1 ? 5 6 1 ? 8 6 1 ? 9 6 1 ? 12 6 1 ? 13 6 1 ? 15 6 1 ? 16 6 1 ? 17 6 1 ? 18 6 1 ? 1 13 1 ? 8 13 1 ? 9 13 1 ? 12 13 1 ...
result:
ok Correct answer
Test #5:
score: 0
Accepted
time: 15ms
memory: 3668kb
input:
500 SECOND FIRST FIRST FIRST FIRST SECOND FIRST FIRST FIRST SECOND FIRST FIRST FIRST FIRST FIRST FIRST FIRST FIRST FIRST FIRST FIRST FIRST SECOND FIRST FIRST FIRST FIRST FIRST FIRST SECOND FIRST FIRST FIRST FIRST FIRST FIRST FIRST FIRST SECOND FIRST FIRST FIRST FIRST FIRST SECOND FIRST FIRST FIRST F...
output:
? 0 413 1 ? 1 413 1 ? 2 413 1 ? 3 413 1 ? 4 413 1 ? 5 413 1 ? 6 413 1 ? 7 413 1 ? 8 413 1 ? 9 413 1 ? 10 413 1 ? 11 413 1 ? 12 413 1 ? 13 413 1 ? 14 413 1 ? 15 413 1 ? 16 413 1 ? 17 413 1 ? 18 413 1 ? 19 413 1 ? 20 413 1 ? 21 413 1 ? 22 413 1 ? 23 413 1 ? 24 413 1 ? 25 413 1 ? 26 413 1 ? 27 413 1 ? ...
result:
ok Correct answer
Test #6:
score: -100
Wrong Answer
time: 42ms
memory: 3768kb
input:
500 EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQ...
output:
? 0 413 1 ? 1 413 1 ? 2 413 1 ? 3 413 1 ? 4 413 1 ? 5 413 1 ? 6 413 1 ? 7 413 1 ? 8 413 1 ? 9 413 1 ? 10 413 1 ? 11 413 1 ? 12 413 1 ? 13 413 1 ? 14 413 1 ? 15 413 1 ? 16 413 1 ? 17 413 1 ? 18 413 1 ? 19 413 1 ? 20 413 1 ? 21 413 1 ? 22 413 1 ? 23 413 1 ? 24 413 1 ? 25 413 1 ? 26 413 1 ? 27 413 1 ? ...
result:
wrong answer Invalid input: Too many queries