QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#488855#8819. CNOI Knowledgemsk_samaWA 0ms9104kbC++201.5kb2024-07-24 15:52:242024-07-24 15:52:24

Judging History

你现在查看的是最新测评结果

  • [2024-07-24 15:52:24]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:9104kb
  • [2024-07-24 15:52:24]
  • 提交

answer

#include <bits/stdc++.h>
#define MISAKA main
#define ll long long
using namespace std;
inline int read(){
   char ch=getchar();int f=1,x=0;
   while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
   while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
   return x*f;
}
const double eps=1e-9;
const int N=1e5+10,inf=1e9,mod=998244353;
int n,a[N],fa[N],len[N],ed=1,cnt=1,num=1;
unordered_map<int,int> ch[N];
void insert(int c){
    int p=ed,np=++cnt;len[np]=len[p]+1;ed=np;
    for(;p&&!ch[p][c];p=fa[p]) ch[p][c]=np;
    if(!p) fa[np]=1;
    else{
        int q=ch[p][c];
        if(len[q]==len[p]+1) fa[np]=q;
        else{
            int nq=++cnt;fa[nq]=fa[q];len[nq]=len[p]+1;
            ch[nq]=ch[q];fa[q]=fa[p]=nq;
            for(;p&&ch[p][c]==q;p=fa[p]) ch[p][c]=nq;
        }
    }
}
int get(int l,int r){
    for(int i=1;i<=cnt;i++) fa[i]=len[i]=0,ch[i].clear();
    int res=0;ed=cnt=1;
    for(int i=l;i<=r;i++) insert(a[i]),res+=len[ed]-len[fa[ed]];
    return res;
}
int ask(int l,int r){cout<<"? "<<l<<' '<<r<<'\n'<<flush;return read();}
signed MISAKA(){
    n=read();a[1]=1;
    for(int i=2;i<=n;i++){
        if(ask(1,i)-get(1,i-1)==i){a[i]=++num;continue;}
        int l=1,r=i-1;
        while(r>=l){
            int mid=l+r>>1;
            if(ask(mid,i)-get(mid,i-1)==i-mid+1) r=mid-1;
            else l=mid+1;
        }
        a[i]=a[r];
    }
    cout<<"! ";
    for(int i=1;i<=n;i++) cout<<a[i]<<' ';cout<<flush;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 9104kb

input:

12
3
6
10
15
21
27
15
27
20
34
14
6
9
43
20
10
14
52
19
9
5
2
62
25
8
5
72
25
9
19
13

output:

? 1 2
? 1 3
? 1 4
? 1 5
? 1 6
? 1 7
? 3 7
? 1 7
? 2 7
? 1 8
? 4 8
? 6 8
? 5 8
? 1 9
? 4 9
? 6 9
? 5 9
? 1 10
? 5 10
? 7 10
? 8 10
? 9 10
? 1 11
? 5 11
? 8 11
? 9 11
? 1 12
? 6 12
? 9 12
? 7 12
? 8 12
! 1 2 3 4 5 6 2 5 4 4 5 5 

result:

wrong answer Wrong Answer.