随笔分类 - 模板
摘要:```cpp include define ll long long define re register define gc get_char define cs const namespace IO{ inline char get_char(){ static cs int Rlen=1 in
阅读全文
摘要:```cpp include using namespace std; typedef long long ll; const int MAXN = 3e5 + 51, MOD = 998244353, G = 3, INVG = 332748118; int exponent, fd, cnt =
阅读全文
摘要:```cpp include using namespace std; typedef long long ll; const int MAXN = 100000 + 5; //MAXN = sqrt(MAXINPUTN) const ll MOD = 1000000007, inv2 = 5000
阅读全文
摘要:```cpp include using namespace std; typedef long long ll; int solve(); int main() { ifdef Yinku freopen("Yinku.in","r",stdin); endif // Yinku solve();
阅读全文
摘要:```cpp include define ll long long using namespace std; //N为n^(2/3)最快 int n; const int MAXN=5e6; unordered_map Smu; unordered_map Sphi; ll sump[MAXN+5
阅读全文
摘要:```cpp include using namespace std; typedef long long ll; int n, m; const int MAXN = 1000005; int tot, v[MAXN], l[MAXN], r[MAXN], d[MAXN]; int gc[MAXN
阅读全文
摘要:```cpp include using namespace std; typedef long long ll; inline int read() { char c = getchar(); int x = 0, f = 1; while(c '9') { if(c == ' ') f = 1;
阅读全文
摘要:普通的SPFA: 带SLF优化的SPFA,实测在某些数据上确实会快(有人说是15%左右,但实际上貌似不止?反正抖得厉害)
阅读全文
摘要:```cpp struct BigInt { const static int BASE = 1000000000; const static int DLEN = 9; vector a; int len; BigInt() { a.resize(4); len = 1; } BigInt(int v) { a.resize(4); len = 0; do { a[len++] = v % BA
阅读全文
摘要:```cpp int dis[105]; bool vis[105]; priority_queue > pq; void dijkstra(int s, int n) { while(!pq.empty()) pq.pop(); for(int i = 1; i dis[u] + w) { dis[v] = dis[u] + w; pq.push({-dis[v], v}); } } } } `
阅读全文
摘要:```cpp const int MOD = 10007; ll n, m; ll qpow(ll x, ll n) { ll res = 1; while(n) { if(n & 1) res = res * x % MOD; x = x * x % MOD; n >>= 1; } ret...
阅读全文
摘要:https://www.acwing.com/problem/content/369/ 一定要小心缩点之后只剩下一个强连通分量(一个孤立点)的时候,本身就是强连通的了。 cpp include using namespace std; typedef long long ll; const int
阅读全文
摘要:```cpp include using namespace std; define ll long long int a[40]; ll dp[40][40][40]; ll dfs(int pos, int s1, int s2, bool lead, bool limit) { if(pos
阅读全文
摘要:区间加值,区间求和的树状数组,通过差分来实现。 并没有线段树那么通用。 cpp include using namespace std; typedef long long ll; ll bit[100005]; ll bit2[100005]; int n; void add(int x, ll
阅读全文
摘要:```cpp include using namespace std; typedef long long ll; inline int gcd(int a,int b){ if(!b) return a; else{ while(int i=a%b){ a=b; b=i; } return b;
阅读全文
摘要:https://www.acwing.com/problem/content/210/ 要注意两点:开关之间的关系不一定是对称的,并且每个开关会控制自己。 消元的过程中可以计算出矩阵的秩,假如某个行没有主元但是有常数,那么就直接 1了。 cpp include using namespace std
阅读全文
摘要:```cpp inline int gcd(int a,int b){ if(b==0) return a; else{ while(int i=a%b){ a=b; b=i; } return b; } } int ex_gcd(int a,int b,int& x,int& y) { if(b==0) { x=1; y=0; return a; } int d=ex_gcd(b,a%b,x,y
阅读全文
摘要:普通平衡树: 非递归的不带修改的查询,方便可持久化: cpp include using namespace std; typedef long long ll; define ls(p) ch[p][0] define rs(p) ch[p][1] const int MAXN = 100000
阅读全文
摘要:```cpp include using namespace std; int n; double r; struct point { double x, y; } p[100005], o; inline double sqr(double x) { return x x; } inline do
阅读全文
摘要:这个是正确的算法,但是复杂度可能会卡到 $O(n^2)$ ,加上每个点最多匹配的临近点最多15个/30个限制的话复杂度就可以保证了,最多就再做一次增加正确的几率,我确实不行从头到尾都是随机的怎么有人卡得掉。 cpp include using namespace std; const double
阅读全文

浙公网安备 33010602011771号