随笔分类 - 模板
摘要:``` cpp const int maxn=255; int val[maxn][maxn]; const int log_maxn=8; int dpmin[maxn][maxn][log_maxn][log_maxn]; int dpmax[maxn][maxn][log_maxn][log_maxn]; void initRMQ(int n,int m) { mm[0]=-1; for(i
阅读全文
摘要:/ 求 无向图的割点和桥 可以找出割点和桥,求删掉每个点后增加的连通块。 需要注意重边的处理,可以先用矩阵存,再转邻接表,或者进行判重 / const int MAXN = 10010; const int MAXM = 100010; struct Edge { int to,next; bool
阅读全文
摘要:int From[maxn], Laxt[maxn], To[maxn G[maxn]; void add(int u, int v) { Next[++cnt] = Laxt[u]; From[cnt] = u; Laxt[u] = cnt; To[cnt] = v; } void tarjan(
阅读全文
摘要:int From[maxn],Laxt[maxn],To[maxnG[maxn]; int dis[maxn],S,T,ans; void add(int u,int v) { Next[++cnt]=Laxt[u]; From[cnt]=u; Laxt[u]=cnt; To[cnt]=v; } v
阅读全文
摘要:题目描述 如题,已知一棵包含N个结点的树(连通且无环),每个节点上包含一个数值,需要支持以下操作: 操作1: 格式: 1 x y z 表示将树从x到y结点最短路径上所有节点的值都加上z 操作2: 格式: 2 x y 表示求树从x到y结点最短路径上所有节点的值之和 操作3: 格式: 3 x z 表示将
阅读全文
摘要:题目描述 给定一个 NN 个点,MM 条有向边的带非负权图,请你计算从 SS 出发,到每个点的距离。 数据保证你能从 SS 出发到任意点。 输入格式 第一行为三个正整数 N, M, SN,M,S。 第二行起 MM 行,每行三个非负整数 u_i, v_i, w_iu i ,v i ,w i
阅读全文
摘要:``` cpp const int MAXN=150; struct bign { int len, s[MAXN]; bign () { memset(s, 0, sizeof(s)); len = 1; } bign (int num) { this = num; } bign (const c
阅读全文
摘要:``` cpp int ten[4] = {1,10,100,1000}; typedef struct BigNumber { int d[1200]; BigNumber(string s) { int i, j, k, len; len = s.size(); d[0] = (len-1)/4+1; fo...
阅读全文
摘要:C. Make a Square time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output You are given a positive in
阅读全文
摘要:``` cpp int a[maxn];//原始输入数组 int st[maxn][25];//st表 void init(int n) { for (int i = 0; i
阅读全文
摘要:``` cpp const double eps = 1e-6; int sgn(double x) { if(fabs(x) operator &(const Line &b)const { Point res = s; if(sgn((s-e)^(b.s-b.e)) == 0) { if(sgn((s-b...
阅读全文
摘要:如果数组元素较大,需要离散化。 cpp include include include include include include include include include include include define ALL(x) (x).begin(), (x).end() defin
阅读全文
摘要:``` cpp string S(ll n){stringstream ss;string s;ss>s;return s;} ll N(string s){stringstream ss;ll n;ss>n;return n;} string rm0(string s){// 去除前导0函数 int i; for(i=0;it.size())t+='0';reverse(t.b...
阅读全文
摘要:Problem Statement On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (ai,bi), and the coo
阅读全文
摘要:Problem Statement You are given a positive integer N. Find the number of the pairs of integers u and v(0≦u,v≦N) such that there exist two non-negative
阅读全文
摘要:/*函数:r进制转换成10进制*/ int rToTen(string n,int r){ //将r进制转为10进制,n是该r进制的字符串表示 int len = n.length(); int ans = 0; int i = 0; while(i<len){ ans*=r; ans+=n[i]-
阅读全文
摘要:ll gcd(ll a,ll b) { if(b==0) { return a; }else { return gcd(b,a%b); } } ll ABS(ll x) { return x num fenmu-> den F(ll num=0,ll den=1) { if(dennum ...
阅读全文

浙公网安备 33010602011771号