类似 Ad-hoc Master II,考虑用仅与深度有关的信息凑出更多信息。
令权值为 深度为 。手玩可知 ,证明考虑把距离某点为 的点的结构列出来后只有最上面两层是奇数个点。
显然有 ,因此可以确定 。
对于 ,由于已知其余点权异或和,只需求所有点权异或和。
考虑两个点的全部信息合起来是什么,发现当它们距离为偶数时是 ,否则是所有点权异或和。
钦定第一个点枚举第二个点去算即可,注意有可能点权全 。
点击查看参考代码
#include<bits/stdc++.h>
#define TIME chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count()
#define rep(i,l,r) for(int qwp=(r),i=(l);i<=qwp;i++)
#define per(i,r,l) for(int qwp=(l),i=(r);i>=qwp;i--)
using namespace std;
namespace ax_by_c{
constexpr int H=20;
constexpr int N=(1<<16)+5;
inline int frint(){int n=0;char c=getchar();while(c<'0'||'9'<c)c=getchar();while('0'<=c&&c<='9')n=n*10+c-48,c=getchar();return n;}
void wrint(int x){if(x>9)wrint(x/10);putchar(x%10+48);}
int h,n,f[N][H*2],xs[H],ans1,ans2;
void slv(){
h=frint(),n=(1<<h)-1;rep(i,1,n)rep(j,1,h*2-2)f[i][j]=frint();
rep(i,1,h-1)xs[i]=0;rep(i,1,n)rep(j,2,h)xs[j-1]^=f[i][j];
rep(i,1,n){
bool F=0;rep(j,1,h-1)F|=f[i][j]!=xs[j];rep(j,h,h*2-2)F|=f[i][j];
if(!F)ans1=i;
}
ans2=0;rep(i,2,n){
int w=0;rep(j,1,h*2-2)if(j&1)w^=f[1][j]^f[i][j];
if(w)ans2=w;
}
rep(i,1,h-1)ans2^=xs[i];
wrint(ans1),putchar(' '),wrint(ans2),putchar('\n');
}
void main(){
int T;T=frint();
while(T--)slv();
}
}
int main(){
auto _Tst=TIME;
ax_by_c::main();
auto _Ted=TIME;
cerr<<"\nTIME:"<<_Ted-_Tst<<'\n';
return 0;
}
/*
ulimit -s 524288
g++ -O2 -std=c++14 -static A.cpp -o A.exe
g++ -O2 -std=c++14 -fsanitize=address,leak,undefined A.cpp -o A.exe
./A.exe
*/