摘要: $BFS$水题~。 const int N=1e5+10; vector<int> g[N]; int din[N]; int dist[N]; int n; int idx; void bfs(int st) { queue<int> q; q.push(st); dist[st]=0; whil 阅读全文
posted @ 2021-04-19 20:04 Dazzling! 阅读(63) 评论(0) 推荐(0) 编辑
摘要: $DFS$水题~。 注意边界$case$:只有一个节点且是得道者。 const int N=1e5+10; vector<int> g[N]; double expand[N]; int n; double m,r; double sum; void dfs(int u,double power) 阅读全文
posted @ 2021-04-19 19:55 Dazzling! 阅读(94) 评论(0) 推荐(0) 编辑
摘要: 5717. 最少操作使数组递增 签到题,每个数至少比前一个数的数值大一,即可满足严格递增。 class Solution { public: int minOperations(vector<int>& nums) { int res=0; for(int i=1;i<nums.size();i++ 阅读全文
posted @ 2021-04-19 19:07 Dazzling! 阅读(40) 评论(0) 推荐(0) 编辑
摘要: 水题~。 const int N=10010; struct Node { string name; int grade; int rank; bool operator<(const Node &W) const { if(grade != W.grade) return grade > W.gr 阅读全文
posted @ 2021-04-19 15:23 Dazzling! 阅读(62) 评论(0) 推荐(0) 编辑
摘要: 并查集裸题。 const int N=10010; int p[N]; int n,m,maxid; int find(int x) { if(x != p[x]) p[x]=find(p[x]); return p[x]; } int main() { cin>>n; for(int i=1;i< 阅读全文
posted @ 2021-04-19 15:14 Dazzling! 阅读(27) 评论(0) 推荐(0) 编辑
摘要: 宽搜就完事了。 const int N=1e5+10; vector<int> g[N]; int dep[N],maxd; int n; void bfs(int root) { queue<int> q; q.push(root); dep[root]=1; while(q.size()) { 阅读全文
posted @ 2021-04-19 14:58 Dazzling! 阅读(59) 评论(0) 推荐(0) 编辑
摘要: 水~。 将给定的点标记已访问,判断其他点是否还存在未标记访问的邻接点。若存在,说明剩余的点不孤立;否则剩余的全为孤立点。 const int N=10010; vector<int> g[N]; bool vis[N]; int n,m,q; bool dfs(int u) { for(int i= 阅读全文
posted @ 2021-04-19 14:50 Dazzling! 阅读(76) 评论(0) 推荐(0) 编辑