QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#808339#9866. Extracting WeightsSylviallineWA 0ms3532kbC++231.5kb2024-12-10 20:00:562024-12-10 20:00:56

Judging History

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

  • [2024-12-10 20:00:56]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3532kb
  • [2024-12-10 20:00:56]
  • 提交

answer

#include<bits/stdc++.h>

using ll = long long;
using namespace std;
void solve();
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
	// cin>>t;
	while(t--)solve();
}
const int N=251;
using B = bitset<N>;
int dep[N],fa[N];
vector<vector<int>>G;
void dfs(int u){
	for(auto v:G[u]){
		if(v==fa[u])continue;
		dep[v]=dep[u]+1;
		fa[v]=u;
		dfs(v);
	}
}

B mat[N];
int n;
bool add(B a){
	for(int i=1;i<=n;i++)if(a[i]){
		if(mat[i].none()){
			mat[i]=a;
			return 1;
		}
		a^=mat[i];
	}
	return 0;
}
void clear(){
	for(int i=1;i<=n;i++)mat[i].reset();
}
void gauss(){
	for(int i=n;i>=2;i--){
		for(int j=i-1;j>=1;j--)if(mat[j][i])
			mat[j]^=mat[i];
	}
}
struct node{
	int x,y;
	B a;
};
void solve(){
	int k;
	cin>>n>>k;
	G.resize(n+1);
	for(int i=1;i<n;i++){
		int x,y;
		cin>>x>>y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	dfs(1);
	vector<node>V;
	V.push_back({0,0,B{"10"}});
	add(B{"10"});
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++){
		int x=i,y=j,c=0;
		B tp{};
		while(x!=y){
			if(dep[x]<dep[y])swap(x,y);
			tp[x]=1;++c;
			x=fa[x];
		}
		if(c!=k)continue;
		tp[x]=1;
		if(add(tp))V.push_back({i,j,tp});
		if(V.size()==n)break;
	}
	if(V.size()!=n){cout<<"NO\n";return;}

	cout<<"? "<<n-1;
	for(auto &[x,y,a]:V)if(x){
		cout<<" "<<x<<" "<<y;
	}
	cout<<endl;
	
	clear();
	for(auto &[x,y,a]:V){
		if(x){
			bool d;cin>>d;
			a[0]=d;
		}
		add(a);
	}
	gauss();
	cout<<"!";
	for(int i=2;i<=n;i++)cout<<" "<<mat[i][0];
	cout<<endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3532kb

input:

4 1
1 2
2 3
2 4

output:

? 3 1 2 2 3 2 4

result:

wrong answer Token parameter [name=ok] equals to "?", doesn't correspond to pattern "[yY][eE][sS]|[nN][oO]"