https://codeforces.com/problemset/problem/525/E 每个仙女有三种情况,枚举一下,n对半分,使得复杂度变成o(k*3^(n/2)) 用map统计的时候,每次如果跑for的话会有很多重复的,这样可以直接存下来前缀和 for(auto i:mp){for(intj=1;j<=25;j++){ mp[i.first][j]+=mp[i.first][j-1]; } } 我第一...
https://codeforces.com/problemset/problem/1304/E 用lca求树上距离 只有3种情况 a->b a->x+x->y+y->b a->y+y->x+x->b 因为距离过长就可以来回走,所以k-len得是偶数 #include <iostream>#include<cstdio>#include<cstdlib>#include<algorithm>#include<cmath>#include<cstring>#defineinf 21474836...
}intquery(intx,inty){if(deep[x]<deep[y]) swap(x,y);intc=deep[x]-deep[y];for(inti=0;i<=log2(c);i++)if((1<=0;i--){if(f[x][i]!=f[y][i]){ x=f[x][i]; y=f[y][i]; } }returnf[x][0]; }intl(intx,inty){returndeep[x]+deep[y]-2*deep[query(x,y)]; ...
To solve the problem, I made a little flashcards site where I could add flashcards of 2 types: general and code. Each card has different formatting. I made a mobile-first website, so I could review on my phone or tablet, wherever I am. Make your own for free: Flashcards site repo...