正文
增加 56 行删除 0 行
123类似 [Ad-hoc Master II](https://uoj.ac/problem/1014),考虑用仅与深度有关的信息凑出更多信息。令权值为 $a$ 深度为 $de$。手玩可知 $\oplus f_{u,k}=\oplus_{de_u=k-1}a_u$,证明考虑把距离某点为 $k$ 的点的结构列出来后只有最上面两层是奇数个点。1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859类似 [Ad-hoc Master II](https://uoj.ac/problem/1014),考虑用仅与深度有关的信息凑出更多信息。令权值为 $a$ 深度为 $de$。手玩可知 $\oplus f_{u,k}=\oplus_{de_u=k-1}a_u$,证明考虑把距离某点为 $k$ 的点的结构列出来后只有最上面两层是奇数个点。显然有 $f_{rt,k-1}=\oplus_{de_u=k-1}a_u$,因此可以确定 $rt$。对于 $w$,由于已知其余点权异或和,只需求所有点权异或和。考虑两个点的全部信息合起来是什么,发现当它们距离为偶数时是 $0$,否则是所有点权异或和。钦定第一个点枚举第二个点去算即可,注意有可能点权全 $0$。:::success[点击查看参考代码]```cpp#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 524288g++ -O2 -std=c++14 -static A.cpp -o A.exeg++ -O2 -std=c++14 -fsanitize=address,leak,undefined A.cpp -o A.exe./A.exe*/```:::