QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#489288#8819. CNOI Knowledgec20150005WA 1ms3964kbC++141.0kb2024-07-24 19:19:442024-07-24 19:19:45

Judging History

你现在查看的是最新测评结果

  • [2024-07-24 19:19:45]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3964kb
  • [2024-07-24 19:19:44]
  • 提交

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();
			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 
*/

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3964kb

input:

12
3
1
6
3
6
3
10
6
10
6
15
10
10
6
21
15
15
10
27
21
20
15
14
10
6
3
9
6
20
14
34
26
43
34
19
14
9
6
5
3
2
1
25
19
8
5
5
2
25
19
9
5
19
13

output:

? 1 2
? 1 1
? 1 3
? 1 2
? 2 4
? 2 3
? 1 4
? 1 3
? 2 5
? 2 4
? 1 5
? 1 4
? 3 6
? 3 5
? 1 6
? 1 5
? 3 7
? 3 6
? 1 7
? 1 6
? 2 7
? 2 6
? 4 8
? 4 7
? 6 8
? 6 7
? 5 8
? 5 7
? 4 9
? 4 8
? 2 9
? 2 8
? 1 9
? 1 8
? 5 10
? 5 9
? 7 10
? 7 9
? 8 10
? 8 9
? 9 10
? 9 9
? 5 11
? 5 10
? 8 11
? 8 10
? 9 11
? 9 10
? ...

result:

wrong answer Wrong Answer.