QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#489361 | #8819. CNOI Knowledge | c20150005 | WA | 1ms | 3736kb | C++14 | 1.1kb | 2024-07-24 19:45:58 | 2024-07-24 19:45:59 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;using ll=long long;
int rd(int x=0,char c=getchar()){int f=1;while(!isdigit(c))f=(c^'-'?1:-1),c=getchar();while(isdigit(c))x=x*10+(c^48),c=getchar();return x*f;}
const int N=1e3+3;
int n,a[N],s[N],S,c[N];
using ull=unsigned long long;
const ull pw=19260817;
ull h[N];
map<ull,int> mp;
int main(){
n=rd();a[1]=s[1]=h[1]=++S;
for(int i=2;i<=n;i++){
memset(c,0,sizeof c);
int l=1,r=i,p=0;
while(l<=r){
int mid=(l+r)>>1;
cout<<"? "<<mid<<" "<<i<<endl;
int x=rd();
// cout<<"? "<<mid<<" "<<i-1<<endl;
// int y=rd();
if(x==s[mid]+i-mid+1)p=mid,r=mid-1;
else p=mid,l=mid+1;
}
if(p==0)a[i]=++S;
else a[i]=a[p];
ull x=0;
for(int j=i;j;j--){
x=x*pw+a[j];
c[mp[x]+1]++;c[j+1]--;
mp[x]=j;
}
for(int j=1;j<=i;j++)c[j]+=c[j-1],s[j]+=c[j];
// for(int j=1;j<=i+1;j++)c[j]=0;
// cerr<<"I: "<<i<<endl;
// for(int j=1;j<=i;j++)cerr<<s[j]<<" ";
// cerr<<endl;
}
cout<<"! ";
for(int i=1;i<=n;i++)printf("%d ",a[i]);
cout<<endl;
return 0;
}
/*
1 2 3 4 5 6 2 5 7 7 5 6
*/
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3736kb
input:
12 3 3 6 6 3 6 3 10 3 6 10 3 6 14 6 3 14 6 3 19 5 14 9 19 5 13 8 25 9 3 6
output:
? 1 2 ? 2 3 ? 1 3 ? 2 4 ? 3 4 ? 3 5 ? 4 5 ? 3 6 ? 5 6 ? 4 6 ? 4 7 ? 6 7 ? 5 7 ? 4 8 ? 6 8 ? 7 8 ? 5 9 ? 7 9 ? 8 9 ? 5 10 ? 8 10 ? 6 10 ? 7 10 ? 6 11 ? 9 11 ? 7 11 ? 8 11 ? 6 12 ? 9 12 ? 11 12 ? 10 12 ! 1 1 1 1 1 1 1 1 1 1 1 1
result:
wrong answer Wrong Answer.