QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#498648 | #8819. CNOI Knowledge | c20150005 | WA | 37ms | 4356kb | C++23 | 1.0kb | 2024-07-30 17:11:14 | 2024-07-30 17:11:19 |
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=26;
ull h[N];
map<ull,int> mp;
int main(){
n=rd();a[1]=s[1]=h[1]=++S;mp[1]=1;
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==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];
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
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3900kb
input:
12 3 3 6 6 10 6 15 10 21 10 20 15 14 6 9 14 34 43 19 5 2 1 19 5 13 8 25 9 19
output:
? 1 2 ? 2 3 ? 1 3 ? 2 4 ? 1 4 ? 3 5 ? 1 5 ? 3 6 ? 1 6 ? 4 7 ? 2 7 ? 3 7 ? 4 8 ? 6 8 ? 5 8 ? 5 9 ? 2 9 ? 1 9 ? 5 10 ? 8 10 ? 9 10 ? 10 10 ? 6 11 ? 9 11 ? 7 11 ? 8 11 ? 6 12 ? 9 12 ? 7 12 ! 1 2 3 4 5 6 2 5 7 7 5 6
result:
ok Accepted. 29 queries used.
Test #2:
score: -100
Wrong Answer
time: 37ms
memory: 4356kb
input:
1000 3 2 1 3 2 1 5 11 7 8 2 1 7 2 1 11 5 7 11 5 3 15 5 2 1 15 3 2 1 19 4 2 1 17 4 2 1 20 4 2 1 15 4 2 1 23 9 13 15 23 11 5 3 31 11 5 3 36 11 5 2 1 45 15 3 2 1 48 15 5 11 7 58 16 5 2 1 59 16 5 12 8 69 21 8 2 1 69 20 8 3 5 79 20 8 2 1 76 20 8 3 5 87 26 8 3 5 88 26 8 2 1 100 24 8 3 5 98 24 8 2 1 111 31...
output:
? 1 2 ? 2 3 ? 3 3 ? 2 4 ? 3 4 ? 4 4 ? 3 5 ? 1 5 ? 2 5 ? 3 6 ? 5 6 ? 6 6 ? 4 7 ? 6 7 ? 7 7 ? 4 8 ? 6 8 ? 5 8 ? 5 9 ? 7 9 ? 8 9 ? 5 10 ? 8 10 ? 9 10 ? 10 10 ? 6 11 ? 9 11 ? 10 11 ? 11 11 ? 6 12 ? 9 12 ? 11 12 ? 12 12 ? 7 13 ? 10 13 ? 12 13 ? 13 13 ? 7 14 ? 11 14 ? 13 14 ? 14 14 ? 8 15 ? 12 15 ? 14 15 ...
result:
wrong answer Wrong Answer.