QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#489300 | #8819. CNOI Knowledge | c20150005 | WA | 250ms | 34500kb | C++14 | 1.0kb | 2024-07-24 19:22:30 | 2024-07-24 19:22:32 |
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,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];
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
*/
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3816kb
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: 0
Accepted
time: 250ms
memory: 34500kb
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:
ok Accepted. 8792 queries used.
Test #3:
score: -100
Wrong Answer
time: 33ms
memory: 3824kb
input:
1000 2 1 2 1 5 7 5 11 8 7 15 11 7 16 11 11 5 8 11 3 2 1 14 3 2 1 11 31 23 17 13 36 27 20 7 4 2 1 15 51 32 23 20 8 2 1 28 12 5 8 31 12 5 8 38 11 3 2 1 38 9 26 20 14 44 14 5 9 44 14 5 11 8 54 15 3 2 1 56 14 3 2 1 65 17 4 2 1 66 17 7 11 76 17 8 2 1 76 20 8 3 5 87 26 8 2 1 88 26 8 3 5 102 26 8 3 5 102 2...
output:
? 1 2 ? 2 2 ? 2 3 ? 3 3 ? 2 4 ? 1 4 ? 3 5 ? 1 5 ? 2 5 ? 3 6 ? 1 6 ? 2 6 ? 4 7 ? 2 7 ? 3 7 ? 4 8 ? 6 8 ? 5 8 ? 5 9 ? 7 9 ? 8 9 ? 9 9 ? 5 10 ? 8 10 ? 9 10 ? 10 10 ? 6 11 ? 3 11 ? 4 11 ? 5 11 ? 6 12 ? 3 12 ? 4 12 ? 5 12 ? 7 13 ? 10 13 ? 12 13 ? 13 13 ? 7 14 ? 3 14 ? 5 14 ? 6 14 ? 8 15 ? 12 15 ? 14 15 ?...
result:
wrong answer Wrong Answer.