CF1365G Secure Password(构造,交互,二进制分组)

CF1365G Secure Password

Solution

妙妙思维题。

注意到 ( 13 6 ) > n \binom{13}{6}>n (613)>n(谁tm能注意到这个?!?)

我们可以把所有13位二进制数中有6个1的拿出来给 n n n个数重标号。然后对于每一位 i i i,求出重标号后这一位是1的数的位或和,记为 w i w_i wi

对于重标号后为 i i i的位置的答案,只需要让所有 i i i的0的位的 w j w_j wj或起来即可。

Code

#include <bits/stdc++.h>

using namespace std;

template<typename T> inline bool upmin(T &x, T y) { return y < x ? x = y, 1 : 0; }
template<typename T> inline bool upmax(T &x, T y) { return x < y ? x = y, 1 : 0; }

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int, int> PR;
typedef vector<int> VI; 

const lod eps = 1e-9;
const lod pi = acos(-1);
const int oo = 1 << 30;
const ll loo = 1ll << 60;
const int mods = 1e9 + 7;
const int inv2 = (mods + 1) >> 1;
const int MAXN = 1005;
const int INF = 0x3f3f3f3f; //1061109567
/*--------------------------------------------------------------------*/


ll a[5005], w[15], num = 0;
vector<ll> V;
signed main() {
#ifndef ONLINE_JUDGE
//	freopen("a.in", "r", stdin);
#endif
	int n;
	cin >> n;
	for (int i = 0; i < 1 << 13 && num < n ; ++ i)
		if (__builtin_popcount(i) == 6) a[++ num] = i;
	for (int i = 0; i < 13 ; ++ i) {
		vector<int> V; V.clear();
		for (int j = 1; j <= n ; ++ j)
			if ((a[j] >> i) & 1) V.PB(j);
		if (!V.size()) continue;
		cout << "? " << V.size();
		for (auto v : V) cout << " " << v; cout << endl;
		cin >> w[i];
	}
	cout << "!";
	for (int i = 1; i <= n ; ++ i) {
		ll ans = 0;
		for (int j = 0; j < 13 ; ++ j)
			if (!((a[i] >> j) & 1)) ans |= w[j];
		cout << " " << ans;
	}
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值