QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#489265 | #8819. CNOI Knowledge | c20150005 | WA | 0ms | 3776kb | C++14 | 1015b | 2024-07-24 19:13:08 | 2024-07-24 19:13:08 |
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++){
int l=1,r=i-1,p=1;
while(l<=r){
int mid=(l+r)>>1;
cout<<"? "<<mid<<" "<<i<<endl;
int x=rd();
if(x==s[mid]+i-mid+1)p=mid,r=mid-1;
else l=mid+1;
}
if(p==1)a[i]=++S;
else a[i]=a[p-1];
for(int j=1;j<=i;j++){
h[j]=h[j]*pw+a[i];
c[mp[h[j]]+1]++;c[j+1]--;
mp[h[j]]=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
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3776kb
input:
12 3 6 6 10 10 15 10 21 15 27 20 14 6 9 20 34 43 19 9 5 2 25 8 5 3 25 9 19 13
output:
? 1 2 ? 1 3 ? 2 4 ? 1 4 ? 2 5 ? 1 5 ? 3 6 ? 1 6 ? 3 7 ? 1 7 ? 2 7 ? 4 8 ? 6 8 ? 5 8 ? 4 9 ? 2 9 ? 1 9 ? 5 10 ? 7 10 ? 8 10 ? 9 10 ? 5 11 ? 8 11 ? 9 11 ? 10 11 ? 6 12 ? 9 12 ? 7 12 ? 8 12 ! 1 2 3 4 5 6 2 5 7 8 7 5
result:
wrong answer Wrong Answer.