QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#803094#9866. Extracting Weightsucup-team918#WA 0ms3528kbC++142.6kb2024-12-07 15:59:142024-12-07 15:59:14

Judging History

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

  • [2024-12-07 15:59:14]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3528kb
  • [2024-12-07 15:59:14]
  • 提交

answer

/* Code by pp_orange */
//#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define m_p(a,b) make_pair(a,b)
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ld long double
#define inf 0x7FFFFFFF
#define inff 9223372036854775807
#define rep(i,l,r) for(int i=l;i<r;++i)
#define repp(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r-1;i>=l;--i)
#define pper(i,r,l) for(int i=r;i>=l;--i)
#define pii pair<int,int>
#define fi first
#define se second
#define p_q priority_queue
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ls(x) ((x)<<1)
#define rs(x) ((x)<<1|1)
#define lb(x) ((x)&-(x))
#define lg(x) (31^__builtin_clz(x))
#define vi vector<int>
#define vii vector<pii >
#define vT vector<T>
#define mm1 mint(1)
const int mod = 998244353;
#define bits bitset<255>
//#define int ll
const int intsz = sizeof(int);
using namespace std;
ll pw(ll x,int d){
	ll t = 1;
	for(;d;d>>=1,x=x*x%mod)if(d&1)t = t*x%mod;
	return t;
}
#define MAX 255
vector<int> v[MAX];
// bits bt[MAX*MAX];
bits bse[MAX];
bits qrbse[MAX];
pii qry[MAX];
int rlt[MAX];
int ans[MAX];
bool ins(bits ve,int idx){
	// repp(i,1,4)cout<<ve[i]<<' ';cout<<endl;
	bits qq; qq[idx] = 1;
	rep(i,0,255){
		if(ve[i]){
			if(bse[i][i]){
				ve ^= bse[i];
				qq ^= qrbse[i];
			}else{
				bse[i] = ve;
				qrbse[i] = qq;
				return 1;
			}
		}
	}
	return 0;
}
int dep[MAX];
int n,k;
bits tmp;
int qrycnt = 0;
void dfs(int x,int fa,int rt){
	tmp[x] = 1;
	dep[x] = dep[fa] + 1;
	if(dep[x] == k && rt <= x){
		if(ins(tmp,qrycnt+1)){
			qry[++qrycnt] = {rt,x};
		}
	}
	for(auto to : v[x]){
		if(to==fa)continue ;
		dfs(to,x,rt);
	}
	tmp[x] = 0;
	return ;
}
signed main(){
	//freopen("E.in","r",stdin);
	//freopen("E.out","w",stdout);
	cin >> n >> k;
	k++;
	tmp[1] = 1;
	ins(tmp,0);
	rep(i,1,n){
		int x,y;
		cin >> x >> y;
		v[x].pb(y);
		v[y].pb(x);
	}
	repp(i,1,n){
		tmp = 0;
		dfs(i,0,i);
	}
	if(qrycnt != n-1){
		cout<<"No"<<endl;
		return 0;
	}
	pper(i,n,1){
		assert(bse[i][i]==1);
		pper(j,i-1,1){
			if(bse[j][i]==1){
				bse[j] ^= bse[i];
				qrbse[j] ^= qrbse[i];
			}
		}
	}
	repp(i,1,n){
		assert(bse[i].count()==1);
	}
	cout << "Yes" << endl;
	cout<<"? ";
	repp(i,1,n-1)cout<<qry[i].fi<<' '<<qry[i].se<<' ';
	cout<<endl;
	repp(i,1,n-1){
		cin >> rlt[i];
	}
	repp(i,1,n){
		repp(j,1,n-1){
			if(qrbse[i][j]){
				ans[i] ^= rlt[j];
			}
		}
	}
	cout<<"! ";
	repp(i,2,n)cout<<ans[i]<<' ';cout<<endl;
	return 0;
}
/*
g++ E.cpp -o E -g -std=c++14 -Wall -Wshadow -fsanitize=undefined,address && ./E < in.in
ulimit -s unlimited
*/

詳細信息

Test #1:

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

input:

4 1
1 2
2 3
2 4
-1

output:

Yes
? 1 2 2 3 2 4 

result:

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