前言:
牛客2021多校Alice and Bob ,在这题中5000 * 5000 * 5000的复杂度,用bitset 140ms,bool 493ms。bitset快到起飞。
AcWing348–最优比率生成树,这题用bitset会TLE,用bool反而AC。
讨论:
如果一直连续访问数组中的元素,bool明显快于bitset。
bool : 26ms
bitset : 108ms
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e6 + 5, mod = 1e9 + 7;
bitset<N> f;
signed main()
{
srand((unsigned)time(0));