[交互][FWT] UOJ #328. 【UTR #3】量子破碎

1 篇文章 0 订阅

Solution S o l u t i o n

矩阵

A=[1111] A = [ 1 1 1 − 1 ]
好像就是 FWT FWT 的变换矩阵。
对每一位都变换以后,考虑FWT的式子。
fS^=TU(1)|ST|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 ,一定满足 |(x xor y) and 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;
}
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值