QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#488761 | #8819. CNOI Knowledge | xinhaowen | TL | 0ms | 0kb | C++14 | 1.2kb | 2024-07-24 15:12:11 | 2024-07-24 15:12:13 |
answer
#include<cstdio>
#include<algorithm>
//#define getchar getchar_unlocked
//#define putchar putchar_unlocked
template<typename T>void read(T &x){
x=0;bool f=0;char ch=getchar();
for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=1;
for(;ch>='0'&&ch<='9';ch=getchar())x=(x<<1)+(x<<3)+(ch^48);
if(f)x=-x;
}
void write(char x){putchar(x);}
template<typename T>void write(T x){
if(x<0)putchar('-'),x=-x;
char stk[24];int cnt=0;
do stk[++cnt]=x%10+48,x/=10;while(x);
for(;cnt;)putchar(stk[cnt--]);
}
template<typename T,typename ...Args>void read(T &x,Args &...args){read(x);read(args...);}
template<typename T,typename ...Args>void write(T x,Args ...args){write(x);write(args...);}
template<typename T>T min(T x,T y){return x<y?x:y;}
template<typename T>T max(T x,T y){return x>y?x:y;}
int n,last[1004],tot;
signed main(){
read(n);
for(int i=1;i<=n;++i){
int l=1,r=i-1,ans=0;
for(;l<=r;){
int mid=(l+r)>>1;
write('!',' ',mid,' ',i,'\n');fflush(stdout);
int tmp;read(tmp);fflush(stdout);
if(tmp==i-mid+1)ans=mid,r=mid-1;
else l=mid+1;
}
last[i]=ans;
}
write('!',' ');
for(int i=1;i<=n;++i)
if(!last[i])write(last[i]=++tot,' ');
else write(last[i]=last[last[i]]);
fflush(stdout);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
12
output:
! 1 2