QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#607549 | #8939. Permutation | UESTC_NLNS | Compile Error | / | / | C++14 | 915b | 2024-10-03 15:17:07 | 2024-10-03 15:17:07 |
Judging History
This is the latest submission verdict.
- [2024-10-03 15:17:07]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-10-03 15:17:07]
- Submitted
answer
#include<bits/stdc++.h>
#define pii pair<int,int>
using namespace std;
map<pii,int> mp;
const int N=1e6+5;
void answer(int x)
{
printf("! %d\n",x);
fflush(stdout);
return;
}
int query(int l,int r)
{
if(mp.find({l,r})!=mp.end()) return mp[{l,r}];
int x;
printf("? %d %d\n",l,r);
fflush(stdout);
scanf("%d",&x);
mp[{l,r}]=x;
return x;
}
void solve(int l,int r)
{
if(l==r)
{
answer(l);
return;
}
int mid=(l+r)/2,lmid,x=query(l,r),y;
if(l+1==r)
{
if(x==l) answer(r);
else answer(l);
return;
}
len=max(2,(int)((r-l)*0.618+l));
if(x<=mid)
{
y=query(l,l+len-1);
if(x==y) solve(l,l+len-1);
else solve(l+len,r);
}
else
{
y=query(r-len+1,r);
if(x==y) solve(r-len+1,r);
else solve(l,r-len);
}
return;
}
int T,n;
int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
solve(1,n);
mp.clear();
}
return 0;
}
Details
answer.code: In function ‘void solve(int, int)’: answer.code:36:9: error: ‘len’ was not declared in this scope 36 | len=max(2,(int)((r-l)*0.618+l)); | ^~~ answer.code: In function ‘int query(int, int)’: answer.code:18:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 18 | scanf("%d",&x); | ~~~~~^~~~~~~~~ answer.code: In function ‘int main()’: answer.code:54:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 54 | scanf("%d",&T); | ~~~~~^~~~~~~~~ answer.code:57:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 57 | scanf("%d",&n); | ~~~~~^~~~~~~~~