Solution S o l u t i o n
矩阵
A=[111−1]
A
=
[
1
1
1
−
1
]
好像就是
FWT
FWT
的变换矩阵。
对每一位都变换以后,考虑FWT的式子。
fS^=∑T⊆U(−1)|S∩T|fT
f
S
^
=
∑
T
⊆
U
(
−
1
)
|
S
∩
T
|
f
T
那么在这道题中
fS^=(−1)|S and x|+(−1)|S and y|
f
S
^
=
(
−
1
)
|
S
a
n
d
x
|
+
(
−
1
)
|
S
a
n
d
y
|
因为此时返回值与平方和有关,那么若
query
query
返回的值为
S
S
,一定满足 为偶数。
每次询问后就暴力看 [1,2n] [ 1 , 2 n ] 内那些不合法,ban掉,直到确定解为止。
好像就过了。。。
#include <bits/stdc++.h>
#include "quantumbreak.h"
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
int query_xor(int n, int t) {
int pty[1 << 16];
double a[2][2];
int ban[1 << 16];
int m = 1 << n;
a[0][0] = sqrt(0.5); a[0][1] = sqrt(0.5);
a[1][0] = sqrt(0.5); a[1][1] = -sqrt(0.5);
memset(pty, 0, sizeof pty);
memset(ban, 0, sizeof ban);
ban[0] = 1;
for (int i = 0; i < m; i++)
pty[i] = pty[i >> 1] ^ (i & 1);
while (19260817) {
for (int i = 0; i < n; i++)
manipulate(a, i);
int x = query();
for (int i = 0; i < m; i++)
if (pty[x & i] == 1)
ban[i] = 1;
int rest = 0;
for (int i = 0; i < m; i++)
rest += ban[i];
if (rest == m - 1) break;
}
for (int i = 0; i < m; i++)
if (!ban[i]) return i;
}