洛谷
Tiya_s
一枚ECNU甜菜
展开
-
p3834——主席树模板题
最近遇到好多题目都是关于主席树的,但是菜菜没有学过,因此学习了一下主席树的模板。这个up大大讲的特别好!参考:网页链接https://www.bilibili.com/video/BV1C4411u7rK?from=search&seid=9313032007306021838#include<bits/stdc++.h>using namespace std;const int maxn=2e5+10;int n,m;int cnt;struct node{原创 2021-05-10 16:44:26 · 102 阅读 · 0 评论 -
p1127——遍历欧拉通路
题目链接(这个题目第一眼看过去感觉和图好像关系不大,以为是一个dfs,后来通过偷窥题解法(这个方法屡试不爽),菜才明白这边是用了欧拉通路的判定用做dfs的剪枝,最后的点不会 TLE。#include<bits/stdc++.h>using namespace std;const int NN=1005;struct DATA//cin和cout用怕了 还是char字符串叭……虽然这个题目好像用string没关系的 这边储存这个字符串和这个字符串的长度{ char s[25]原创 2020-06-25 14:40:28 · 212 阅读 · 0 评论 -
p2865——次短路模版(据说数据有点水?
题目链接#include<bits/stdc++.h>using namespace std;#define INF 0x3f3f3f3fconst int NN=50005;struct edge{ int from,to; int next; double cost;} edge[1000005];//边的数量比较大(比点的数量大好多惹) 开大一些数组int head[NN];int N,R;int d[NN];int dis2[NN];int原创 2020-06-19 14:56:37 · 165 阅读 · 0 评论 -
p3372——线段树模版
题目链接对样例的树这样画w从上到下标区间【0-4】这个是tree【0】【0-2】是tree【1】【3-4】是tree【2】【0-1】是tree【3】【2】是tree【4】【3】是tree【5】【4】是tree【6】【0】是tree【7】【1】是tree【8】接下来的都是空结点然后看代码叭#include<bits/stdc++.h>using namespace std;#define MAX_LEN 500040#define MAXN 100010//储原创 2020-06-17 09:05:36 · 95 阅读 · 0 评论 -
p1993——差分约束系统(dfs的SPFA)
题目链接#include<bits/stdc++.h>using namespace std;const int NN=20005;const int INF=0x3f3f3f3f;struct edge{ int from,to,cost,next; edge() { next=-1; }} edge[NN];int n,m;int d[NN];int head[NN];bool vis[NN];int cnt=0;bo原创 2020-06-16 09:56:10 · 93 阅读 · 0 评论 -
p3379——LCA模版题
题目链接#include<bits/stdc++.h>using namespace std;//LCA(Least Common Ancestors),即最近公共祖先,是这样一个问题: 在有根树中,找出某两个结点 u和 v最近的公共祖先(或者说,离树根最远的公共祖先)。//倍增解法 倍增解法的核心是分治思想。//当已知两个点在树中的深度时,先让较深的结点向上走,直到两个结点深度一样;再二分找出离他们最近的公共祖先。//我们记一个结点的父结点为它的 2^0=1 倍祖先,它的父结点的父原创 2020-06-13 00:42:22 · 142 阅读 · 0 评论 -
p5410——KMP扩展模板题
题目链接#include<iostream>#include<string>#include<cstring>#include<algorithm>#include<cstdio>using namespace std;const int NN=20000005;int m,n;int extend[NN];int nexts[NN];char S[NN],T[NN];//两段相似代码//nexts[i]: T[i]...原创 2020-06-12 13:50:21 · 85 阅读 · 0 评论