摘要: 题目大意: 给出一个01矩阵,求每个0移动(每次可以向有公共边的格子移动一步)到矩阵边界至少要经过多少个1。 考虑建最短路模型,将矩阵中的每个位置拆分为入点和出点,矩阵外部设为一个点。 枚举矩阵中的每个位置: 如果这个位置在矩阵边界,矩阵外部向这个位置的入点连一条长度为0的边。 如果这个位置是上的数 阅读全文
posted @ 2024-05-16 15:45 Alric 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 题目大意: 给出数组a,问对于所有满足\(1\le k\le n\)的奇数\(k\),\(f([a_1,a_2,...,a_k])\)的值。\(f([a_1,a_2,...,a_n])\)的值为对数组\([a_1,a_2,...,a_n]\)进行\(\frac{n+1}{2}\)次操作(选择数组中的 阅读全文
posted @ 2024-05-16 15:20 Alric 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 题目大意: \(f(x)=\begin{cases} x,1\le x\le9\\ f(x的各数位之和),x>9\\ \end{cases}\) 求\(\sum_{i=1}^{n}f(i)\)。 根据打表找规律,我们会发现\(f(x)=(x-1)\bmod 9+1\)。 所以\(\sum_{i=1} 阅读全文
posted @ 2024-05-16 14:49 Alric 阅读(2) 评论(0) 推荐(0) 编辑
摘要: () [] -> . ! ~ * / % + - << >> < <= > >= == != & ^ | && || ?: = += -= *= /= %= &= ^= |= <<= >>= , 阅读全文
posted @ 2024-02-19 16:51 Alric 阅读(5) 评论(0) 推荐(0) 编辑
摘要: KMP #include<bits/stdc++.h> using namespace std; typedef long long ll; const ll N=1e6+10; char s1[N],s2[N]; ll n1,n2,nt[N],f[N]; int main(){ cin >> (s 阅读全文
posted @ 2024-01-24 17:17 Alric 阅读(4) 评论(0) 推荐(0) 编辑
摘要: #include<bits/stdc++.h> using namespace std; typedef long long ll; const ll N=1e5+10; vector<ll> G[N],ans; ll n,m,du[N],cur[N],s=1; void dfs(ll u){ fo 阅读全文
posted @ 2024-01-24 16:35 Alric 阅读(6) 评论(0) 推荐(0) 编辑
摘要: 求割点 #include<bits/stdc++.h> using namespace std; typedef long long ll; const ll N=2e4+10; ll n,m,dfn[N],low[N],tot,root; bool cut[N]; vector<ll> G[N]; 阅读全文
posted @ 2024-01-24 13:28 Alric 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 求欧拉函数 ll calphi(ll x){ ll ret=x; for(ll i=2;i<=x/i;i++){ if(x%i==0){ ret=ret/i*(i-1); while(x%i==0)x/=i; } } if(x>1)ret=ret/x*(x-1); return ret; } 求莫比 阅读全文
posted @ 2024-01-07 17:14 Alric 阅读(2) 评论(0) 推荐(0) 编辑
摘要: #include<bits/stdc++.h> using namespace std; typedef long long ll; const ll N=1e7+10; struct node{ll ls,rs,fa,pri;}t[N]; ll n; int main(){ ios::sync_w 阅读全文
posted @ 2024-01-06 22:37 Alric 阅读(6) 评论(0) 推荐(0) 编辑
摘要: 普通平衡树 #include<bits/stdc++.h> using namespace std; typedef long long ll; const ll N=1e5+10; ll root,tot; struct node{ll ls,rs,val,pri,sz;}t[N]; void p 阅读全文
posted @ 2024-01-06 14:44 Alric 阅读(2) 评论(0) 推荐(0) 编辑