社区讨论

求调(玄关)

CF1363D Guess The Maximums参与者 1已保存回复 0

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
0 条
当前快照
1 份
快照标识符
@mhj27kg7
此快照首次捕获于
2025/11/03 19:31
4 个月前
此快照最后确认于
2025/11/03 19:31
4 个月前
查看原帖
CPP
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e3+10;
int t,n,k,cnt[N],p[N];
vector<int> a[N];
int query(int l,int r){
	int x;
	cout<<"? "<<r-l+1<<" ";
	for(int i=l;i<=r;i++){
		cout<<i<<" ";
	}
	cout<<endl;
	scanf("%lld",&x);
	return x;
}
void solve(){
	scanf("%lld %lld",&n,&k);
	for(int i=1;i<=n;i++){
		p[i]=0;
	}
	for(int i=1;i<=k;i++){
		scanf("%lld",&cnt[i]);
		a[i].push_back(0);
		for(int j=1;j<=cnt[i];j++){
			int x;
			scanf("%lld",&x);
			p[x]=i;
			a[i].push_back(x);
		}
	}
	int l=1,r=n,maxn=query(1,n);
	while(l<r){
		int mid=(l+r)>>1;
		if(query(l,mid)==maxn)r=mid;
		else l=mid+1;
	}
	int x=0;
	if(p[l]){
		cout<<"? "<<n-cnt[p[l]]<<" ";
		for(int i=1;i<=n;i++){
			if(p[i]!=p[l])cout<<i<<" ";
		}	
		cout<<endl;
		scanf("%lld",&x);
	}
	cout<<"! ";
	for(int i=1;i<=k;i++){
		if(i!=p[l]){
			cout<<maxn<<" ";
		}else{
			cout<<x<<" ";
		}
	}
	cout<<endl;
	for(int i=1;i<=k;i++){
		a[i].clear();
	}
}
signed main(){
	scanf("%lld",&t);
	while(t--){
		solve();
	}
	return 0;
}             
/*10
5 5
2 5 1 3 4
1 5
1 3
1 1
1 2
1 4*/                                                                 
错的数据:
CPP
10
5 5
2 5 1 3 4
1 5
1 3
1 1
1 2
1 4
7 7
1 5 3 7 2 6 4
1 2
1 6
1 3
1 7
1 1
1 5
1 4
7 7
7 6 1 3 5 4 2
1 6
1 5
1 7
1 4
1 1
1 2
1 3
4 4
4 3 2 1
1 1
1 3
1 2
1 4
5 5
5 1 3 2 4
1 1
1 4
1 5
1 3
1 2
4 4
1 4 2 3
1 1
1 3
1 4
1 2
5 5
1 3 2 5 4
1 4
1 5
1 2
1 1
1 3
10 10
8 3 5 2 10 4 7 9 6 1
1 10
1 1
1 3
1 9
1 4
1 6
1 2
1 8
1 7
1 5
3 3
3 2 1
1 1
1 3
1 2
6 6
6 2 4 3 1 5
1 1
1 3
1 4
1 2
1 5
1 6

Output
5
Checker Log
wrong output format Expected int32, but "140697941457568" found


回复

0 条回复,欢迎继续交流。

正在加载回复...