QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#829992 | #8939. Permutation | 2021cyq | Compile Error | / | / | C++14 | 2.2kb | 2024-12-24 15:20:55 | 2024-12-24 15:20:56 |
Judging History
This is the latest submission verdict.
- [2024-12-24 15:20:56]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-12-24 15:20:55]
- Submitted
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(5)-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=ceil(r-G*(r-l+1)+1);
if(mid1<x&&x<mid2)mid1++l
if(x<=mid1)
{
if(ask(l,mid1)==x)find(l,mid1,x);
else find(mid1+1,r,ask(mid1+1,r));
}
else{
// if(x<mid2)printf("fuck %d %d %d %d\n",l,r,mid1,mid2);
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));
}
详细
answer.code: In function ‘void find(int, int, int)’: answer.code:51:33: error: expected ‘;’ before ‘l’ 51 | if(mid1<x&&x<mid2)mid1++l | ^ | ; answer.code: In function ‘int main()’: answer.code:65:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 65 | int T,n;scanf("%d",&T); | ~~~~~^~~~~~~~~ answer.code:66:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 66 | while(T--)scanf("%d",&n),find(1,n,ask(1,n)); | ~~~~~^~~~~~~~~