QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#829965 | #8939. Permutation | 2021cyq | WA | 0ms | 3804kb | C++14 | 2.1kb | 2024-12-24 15:10:11 | 2024-12-24 15:10:11 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define bll __int128
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define sec second
#define vii vector<int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define pii pair<int,int>
#define pil pair<int,ll>
#define re register
#define puu pair<ull,ull>
#define clr clear
#define vpi vector<pii>
#define qii queue<int>
using namespace std;
namespace io{
const int __SIZE=(1<<22)+1;
char ibuf[__SIZE],*iS,*iT,obuf[__SIZE],*oS=obuf,*oT=oS+__SIZE-1,__c,qu[55];int __f,qr,_eof;
#define Gc()(iS==iT?(iT=(iS=ibuf)+fread(ibuf,1,__SIZE,stdin),(iS==iT?EOF:*iS++)):*iS++)
inline void flush(){fwrite(obuf,1,oS-obuf,stdout),oS=obuf;}
inline void gc(char&x){x=Gc();}
inline void pc(char x){*oS++=x;if(oS==oT)flush();}
inline void pstr(const char*s){int __len=strlen(s);for(__f=0;__f<__len;++__f)pc(s[__f]);}
inline void gstr(char*s){for(__c=Gc();__c<32||__c>126||__c==' ';)__c=Gc();
for(;__c>31&&__c<127&&__c!=' ';++s,__c=Gc())*s=__c;*s=0;}
template<class I>inline bool read(I&x){_eof=0;
for(__f=1,__c=Gc();(__c<'0'||__c>'9')&&!_eof;__c=Gc()){if(__c=='-')__f=-1;_eof|=__c==EOF;}
for(x=0;__c<='9'&&__c>='0'&&!_eof;__c=Gc())x=x*10+(__c&15),_eof|=__c==EOF;x*=__f;return!_eof;}
template<class I>inline void write(I x){if(!x)pc('0');if(x<0)pc('-'),x=-x;
while(x)qu[++qr]=x%10+'0',x/=10;while(qr)pc(qu[qr--]);}
struct Flusher_{~Flusher_(){flush();}}io_flusher_;
}using io::pc;using io::gc;using io::pstr;using io::gstr;using io::read;using io::write;
const double G=(sqrt(3)-1.0)/2.0;
int ask(int l,int r)
{
if(l==r)return 0;
int x;
cout<<"? "<<l<<" "<<r<<endl;
cin>>x;
return x;
}
void find(int l,int r,int x)
{
if(l==r){printf("! %d",l),cout<<endl;return ;}
int mid1=l+G*(r-l+1)-1,mid2=r-G*(r-l+1)+1;
if(x<=mid1)
{
if(ask(l,mid1)==x) find(l,mid1,x);
else find(mid1+1,r,ask(mid1+1,r));
}
else{
if(ask(mid2,r)==x) find(mid2,r,x);
else find(l,mid2-1,ask(l,mid2-1));
}
}
int main()
{
int T,n;scanf("%d",&T);
while(T--)scanf("%d",&n),find(1,n,ask(1,n));
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3804kb
input:
3 5 3 5 2 2
output:
? 1 5 ? 4 5 ? 1 3 ? 2 3 ! 2
result:
wrong answer Wrong prediction (test case 1)