QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#489297 | #8819. CNOI Knowledge | c20150005 | TL | 0ms | 0kb | C++14 | 1.0kb | 2024-07-24 19:21:36 | 2024-07-24 19:21:37 |
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,p=1;
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==y+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
Time Limit Exceeded
input:
12 3 1 3 1 6 3 6 3 10 6 6 3 15 10 10 6 21 15 10 6 20 15 15 10 14 10 6 3 9 6 14 9 34 26 43 34 19 14 5 3 2 1 1
output:
? 1 2 ? 1 1 ? 2 3 ? 2 2 ? 1 3 ? 1 2 ? 2 4 ? 2 3 ? 1 4 ? 1 3 ? 3 5 ? 3 4 ? 1 5 ? 1 4 ? 3 6 ? 3 5 ? 1 6 ? 1 5 ? 4 7 ? 4 6 ? 2 7 ? 2 6 ? 3 7 ? 3 6 ? 4 8 ? 4 7 ? 6 8 ? 6 7 ? 5 8 ? 5 7 ? 5 9 ? 5 8 ? 2 9 ? 2 8 ? 1 9 ? 1 8 ? 5 10 ? 5 9 ? 8 10 ? 8 9 ? 9 10 ? 9 9 ? 10 10 ? 10 9