QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#488862#8819. CNOI KnowledgexinhaowenTL 0ms1256kbC++141.3kb2024-07-24 15:56:202024-07-24 15:56:28

Judging History

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

  • [2024-07-24 15:56:28]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:1256kb
  • [2024-07-24 15:56:20]
  • 提交

answer

#include<cstdio>
#include<algorithm>
//#define getchar getchar_unlocked
//#define putchar putchar_unlocked
template<typename T>void read(T &x){
	x=0;bool f=0;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=(x<<1)+(x<<3)+(ch^48);
	if(f)x=-x;
}
void write(char x){putchar(x);}
template<typename T>void write(T x){
	if(x<0)putchar('-'),x=-x;
	char stk[24];int cnt=0;
	do stk[++cnt]=x%10+48,x/=10;while(x);
	for(;cnt;)putchar(stk[cnt--]);
}
template<typename T,typename ...Args>void read(T &x,Args &...args){read(x);read(args...);}
template<typename T,typename ...Args>void write(T x,Args ...args){write(x);write(args...);}
template<typename T>T min(T x,T y){return x<y?x:y;}
template<typename T>T max(T x,T y){return x>y?x:y;}
int n,last[1004],tot,ans[1004][1004];
signed main(){
	read(n);
	for(int i=1;i<=n;++i){
		int l=1,r=i-1,jk=0;
		for(;l<=r;){
			int mid=(l+r)>>1;
			write('?',' ',mid,' ',i,'\n');fflush(stdout);
			int tmp,op;read(tmp);ans[mid][i]=tmp;
			if(ans[mid][i-1])op=ans[mid][i-1];
			else write('?',' ',mid,' ',i-1,'\n'),fflush(stdout),read(op);
			if(tmp-op==i-mid+1)r=mid-1;
			else jk=mid,l=mid+1;
		}
		jk?last[i]=last[jk]:last[i]=++tot;
	}
	write('!',' ');
	for(int i=1;i<=n;++i)write(last[i],' ');
	fflush(stdout);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 1256kb

input:

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

output:

? 1 2
? 1 1
? 1 3
? 2 4
? 2 3
? 1 4
? 2 5
? 1 5
? 3 6
? 3 5
? 1 6
? 3 7
? 1 7
? 2 7
? 2 6
? 4 8
? 4 7
? 6 8
? 6 7
? 5 8
? 5 7
? 4 9
? 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
? 8 11
? 9 11
? 6 12
? 6 11
? 9 12
? 7 12
? 7 11
! 1 2 3 4 5 6 2 5 7 7 5 6 

result:

ok Accepted. 42 queries used.

Test #2:

score: -100
Time Limit Exceeded

input:

1000
3
1
5
2
1
3
2
1
7
11
7
8
5
5
3
2
1
11
3
2
1
11
7
5
7
15
8
5
3
3
1
15
11
8
5
2
1
19
7
3
2
1
19
15
4
3
2
1
23
5
3
2
1
20
17
5
4
3
2
1
23
5
4
3
2
1
23
15
9
4
13
6
15
7
31
14
8
5
5
3
3
1
31
23
15
11
7
5
3
1
41
16
11
8
5
2
1
45
36
15
11
7
3
2
1
55
20
7
15
11
11
58
48
21
8
5
5
3
2
1
68
21
16
8
5
69
5...

output:

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

result: