泉九林
泉九林
全部文章
分类
归档
标签
去牛客网
登录
/
注册
泉九林的博客
全部文章
(共7篇)
题解 | 小红的01子序列构造(easy)
双指针解法若区间内总数少于要求个数则右界右移 若区间内总数多于要求个数则左界右移 #include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios::sync_with_...
2025-12-29
0
15
题解 | 小苯点兵点将
#include <stdio.h> int main() { int a, b; scanf("%*d",&a); while(scanf("%d %d",&a,&b)==2){ i...
2025-12-22
0
15
题解 | 上司的舞会
其实只需找到最长的上级关系链即可得出答案对于所有非-1的值都通过递归确定上级数 其中上级数目最多的就是上级关系链最长的 也就是答案(员工+员工的上级总数) #include <bits/stdc++.h> using namespace std; int a,cnt=1; vector...
2025-12-17
0
10
题解 | 小红走矩阵
思路:用二维vector统计重复路径(走过的置1)用dfs()递归走右下 用stay()检视路径是否合法,很明显 这会超时 #include <bits/stdc++.h> using namespace std; typedef long long ll; ll cnt,n,m;//...
2025-12-17
0
13
题解 | 求树的根
vector结合pair形式用vector结合pair直接统计每个节点的出度和入度 (指向其他节点次数和被其他节点指向次数)出度为0的为叶 入度为1的为根(只输出第一个) #include <bits/stdc++.h> using namespace std; int main(){...
2025-12-16
0
19
题解 | 图的分类
用vector直接统计节点所连边的条数解决(4ms) #include <bits/stdc++.h> #include <vector> using namespace std; int main() { cin.tie(0);ios::sync_with_std...
2025-12-16
0
15
题解 | 【模板】链式前向星
#include <bits/stdc++.h> using namespace std; int main(){ int a,b,cnt=0; cin>>a>>b; if(a==1){ cout<<"...
2025-12-16
0
17