首页
控制台
留言板
分类
时间轴
关于我
Login
Menu
首页
控制台
留言板
分类
时间轴
关于我
十七
Archives
2022 / 01
acwing240. 食物链
2022-01-14
acwing
#并查集
题目描述动物王国中有三类动物 A,B,C,这三类动物的食物链构成了有趣的环形。A 吃 B,B 吃 C,C 吃 A。现有 N 个动物,以 1∼N 编号。每个动物都是 A,B,C 中的一种,但是我们并不知道它到底是哪一种。有人用两种说法对这 N 个动物所构成的食物链关系进行描述:第一种说法是 1 X Y
acwing837. 连通块中点的数量
2022-01-13
acwing
#并查集
#include<iostream>#define read(x) scanf("%d",&x)using namespace std;const int MAX=1e5+10;int father[MAX],n,m,x,y,sz[MAX];string op
leetcode40. 组合总和 II
2022-01-13
leetcode
#dfs
#中等
思路由于这里每个元素不能重复,所以每次dfs()时要+1,并且为了去重,可以先将元素排序class Solution { public: vector<vector<int>> ans; vector<int>path; vector<
leetcode39. 组合总和
2022-01-12
leetcode
#dfs
#中等
思路如下:1、遍历数组中的每一个数字。2、递归枚举每一个数字可以选多少次,递归过程中维护一个target变量。如果当前数字小于等于target,我们就将其加入我们的路径数组path中,相应的target减去当前数字的值。也就是说,每选一个分支,就减去所选分支的值。3、当target == 0时,表示
acwing1969. 品种邻近
2022-01-12
acwing
#滑动窗口
思路在间隔k之间找到一个与id相同的即可,可以联想到滑动窗口。对于开始的每个x入栈,对应的ID[x]++,然后在间隔k之后开始出栈,每次出栈后ID[x]--,若ID[x]不为0说明此时在k之内存在相同品种,更新最值。#include<iostream>#include<queue&
acwing143. 最大异或对
2022-01-12
acwing
#Trie
#include<iostream>using namespace std;const int N=1e5+10,M=3100010;//一个字符最多需要31位int a[N],son[M][2],idx;void insert(int x){ int p=0; for(in
acwing154. 滑动窗口
2022-01-11
acwing
#单调队列
acwing830. 单调栈
2022-01-10
acwing
#栈
#include<iostream>using namespace std;const int N=1e5+10;int sk[N],top;int main(){ int n;cin>>n; while(n--){ int x;cin>>
acwing3302. 表达式求值
2022-01-10
acwing
acwing826. 单链表
2022-01-06
acwing
#链表
#include<iostream>using namespace std;const int N=1e5+10;int head,e[N],ne[N],idx;void init(){//初始化 head=-1; idx=0;}void add_to_head(int x)
Previous
37 / 43
Next