QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#809880#9866. Extracting Weightsucup-team191#WA 1ms3564kbC++231.8kb2024-12-11 18:01:562024-12-11 18:01:56

Judging History

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

  • [2024-12-11 18:01:56]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3564kb
  • [2024-12-11 18:01:56]
  • 提交

answer

#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using pii=pair<int,int>;
#define all(a) begin(a),end(a)
#define pb push_back

const int N=310,MOD=1e9+7;
const char en='\n';
const ll LLINF=1ll<<60;
using bs=bitset<251>;

bool le(bs a,bs b)
{
	if (a==b) return 0;
	return b[(a^b)._Find_first()];
}

vector<pair<bs,int>> baz;
bs praz;

bool dod(bs x,int v)
{
	for (auto a: baz) if (le(x^a.x,x))
	{
		x^=a.x;
		v^=a.y;
	}
	if (x==praz) return 0;
	baz.pb({x,v});
	return 1;
}

int getVal(bs x)
{
	int v=0;
	for (auto a: baz) if (le(x^a.x,x))
	{
		x^=a.x;
		v^=a.y;
	}
	assert(x==praz);
	return v;
}

int n,k,de[N],par[N];
vi ch[N];

void dfs(int i,int p=-1)
{
	par[i]=p;
	for (auto x: ch[i]) if (x!=p)
	{
		de[x]=de[i]+1;
		dfs(x,i);
	}
}

vi path(int a,int b)
{
	vi pa,pb;
	while (a!=b)
	{
		if (de[a]<de[b])
		{
			pb.pb(b);
			b=par[b];
		}
		else
		{
			pa.pb(a);
			a=par[a];
		}
	}
	reverse(all(pb));
	pa.pb(a);
	for (auto x: pb) pa.pb(x);
	return pa;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>k;
	for (int i=1;i<n;++i)
	{
		int a,b;
		cin>>a>>b;
		ch[a].pb(b);
		ch[b].pb(a);
	}
	dfs(1);
	vector<pair<bs,pii>> dob;
	for (int i=1;i<=n;++i) for (int j=i+1;j<=n;++j)
	{
		vi p=path(i,j);
		if ((int)p.size()==k+1)
		{
			bs b=praz;
			for (auto x: p) if (x!=1) b[x]=1;
			if (dod(b,0)) dob.pb({b,{i,j}});
		}
	}
	if ((int)dob.size()!=n-1)
	{
		cout<<"NO\n";
		exit(0);
	}
	cout<<"YES\n"<<dob.size();
	for (auto x: dob) cout<<' '<<x.y.x<<' '<<x.y.y;
	cout<<endl;
	baz.clear();
	for (auto x: dob)
	{
		int v;
		cin>>v;
		dod(x.x,v);
	}
	cout<<"!";
	for (int i=2;i<=n;++i)
	{
		bs b=praz;
		b[i]=1;
		cout<<' '<<getVal(b);
	}
	cout<<endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 1
1 2
2 3
2 4

output:

YES
3 1 2 2 3 2 4

result:

wrong answer Token "3" doesn't correspond to pattern "?"