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...
4. 5. 我第一次尝试用这种方式存前缀和,只能说auto太好用啦 #include <iostream>#include<algorithm>#include<stdio.h>#include<string.h>#include<string>#include<cmath>#include<assert.h>#include<queue>#include<stack>#include<stdlib.h>#include<ctime>#include#include<unordered_map>typedeflonglongll;...
}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)]; ...
Rapid Void Crew fire ship, Biomass Void Crew resource set, Void Crew gun no overheating, Resource Void Crew set alloy, Repairing instant Void Crew, Health Void Crew pc infinite, Void Crew ignore perk hack, Set speed multiplier Void Crew, Void Crew set bio ReacTkinter (Retink) is a proof...
Codeforces For your Coding Interview You can use a language you are comfortable in to do the coding part of the interview, but for large companies, these are solid choices: C++ Java Python You could also use these, but read around first. There may be caveats: JavaScript Ruby Here is an ...
https://codeforces.com/contest/1301/problem/B,https://codeforces.com/contest/1301/problem/B如果填的这个数特别大,显然不优,如果数特别小,也不优,所以它是凸函数,可以二分(整数单峰函数二分模板题#include<iostream>#include<cstdio>#include<queue