shyyhs
shyyhs
全部文章
题解
DP专题(52)
图论(4)
多校补题(2)
数据结构(27)
数论(4)
日记(14)
未归档(38)
归档
标签
去牛客网
登录
/
注册
shyyhs的博客
全部文章
/ 题解
(共329篇)
Subway
来自专栏
dfs找环的那个代码写的很烂= - =思路挺简单的,你找到环然后bfs一下就完事了 #include <bits/stdc++.h> using namespace std; const int N=3e3+5; vector<int>v[N]; vector<int&...
DFS
BFS
2020-09-09
0
528
Discrete Centrifugal Jumps
来自专栏
这个题挺简单的(2333).首先我们想一个问题.假如这个题的算法是(单调栈+dp),那应该怎么做才能ac.单调栈无非就是维护一个单调序列,因为跳跃方式只有两种,如下图:而单调栈维护的是一种序列的单调性,我们很容易知道,假如我维护的序列是从后往前单调递减的,那么转移肯定只能在两个栈头和这个之间转移,同...
单调栈
DP
2020-09-09
1
845
Destroying Array
来自专栏
写代码一定要规范,不然很多玄学错误,你都搞不懂...2333 #include <bits/stdc++.h> using namespace std; const int N=1e5+5; int a[N],fa[N],b[N]; long long sum[N]; int f(in...
并查集
2020-09-09
2
571
Jamie and Interesting Graph
来自专栏
看上去很复杂,其实你只要把构造一条链,使得他们的和为1e6+3(>n的质数),就好了,然后其他边为1e9,然后就ac了.代码如下: #include <bits/stdc++.h> using namespace std; const int N=2e5+5; struct vv{...
图论
2020-09-08
1
528
Decorate Apple Tree
来自专栏
直接统计下每个节点有多少叶子节点,排序输出即可. #include <bits/stdc++.h> using namespace std; const int N=1e5+5; vector<int>v[N]; int dp[N]; void dfs(int u) { ...
DFS
2020-09-08
1
676
Fight Against Traffic
来自专栏
建个图,跑两个bfs算下距离,假如不是因为这条边的产生使得距离变短了,就ans++.n^2枚举添加的边.代码如下: #include <bits/stdc++.h> using namespace std; const int N=1e3+5; vector<int>v[N]...
BFS
2020-09-08
0
635
Mike and Shortcuts
来自专栏
建图跑个bfs就好了= - = #include <bits/stdc++.h> using namespace std; const int N=2e5+5; vector<int>v[N]; int vis[N],dis[N]; queue<int>q; vo...
BFS
2020-09-08
0
625
Fair
来自专栏
一个题目数据小就是那个题目的突破点(一般),比如这个题目,大家貌似都能想到n^2的,但是大家看一眼k的大小会发现,这题的突破点在k(这题不是水题= - =).考虑对于没种颜色做一次bfs,算出其他点到这种颜色的最短距离.代码如下: #include <bits/stdc++.h> usi...
BFS
2020-09-08
0
507
Spanning Tree with Maximum Degree
来自专栏
#include <bits/stdc++.h> using namespace std; const int N=2e5+5; struct vv{ int from,to; }; int vis[N];//不能走到重复点. vector<int>v[N]; vec...
BFS
2020-09-07
2
599
Love Rescue
来自专栏
#include <bits/stdc++.h> using namespace std; const int N=1e5+5,M=30; char s1[N],s2[N]; int fa[M]; struct vv{ int t,m; }; vector<vv>v;...
并查集
2020-09-07
1
606
首页
上一页
14
15
16
17
18
19
20
21
22
23
下一页
末页