题目链接 SCOJ TOPOI 题目描述 Problem 给定一个包含n个顶点m条边的带权有向图,找一条边数最多的路径,且路径上的边的权值严格递增.图中可能有重边和自环. Input Data 第一行,两个整数n和m,表示顶点数和边数.接下来m行,每行三个整数u,v,w,表示顶点u到顶点v有一条权值为w的边. Output Data 一行,一个整数. Input Sample 1 3 31 2 12 3 23 1 3 Output Sample 1 3 Input Sample 2 6 7 1…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 并查集 日期 题目地址:https://leetcode-cn.com/problems/number-of-connected-components-in-an-undirected-graph/ 题目描述 Given n nodes labeled from 0 to n - 1 and a list of undirected edges (ea…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 DFS BFS 日期 题目地址:https://leetcode.com/problems/clone-graph/ 题目描述 Given a reference of a node in a connected undirected graph, return a deep copy (clone) of the graph. Each node…
Clone GraphClone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJ's undirected graph serialization:Nodes are labeled uniquely. We use # as a separator for each node, and , as a separator for node label and…
题意: 给一棵树,树的每条边有一种颜色,黑色或白色,一开始所有边均为黑色,有两个操作: 操作1:将第i条边变成白色或将第i条边变成黑色. 操作2 :询问u,v两点之间仅经过黑色变的最短距离. 树链剖分+树状数组 学习树链剖分: /* 树链剖分: 划分轻重链,效果是将一颗树变成了若干段连续的区间. 向上记录边权 */ #include <iostream> #include <cstdio> #include <cstring> #include <cmath>…
4427: Miss Zhao's Graph 题目连接: http://acm.scu.edu.cn/soj/problem.action?id=4427 Description Mr Jiang gives Miss Zhao a problem about graphs. Unfortunately, she is not very good at graph theory. However, she doesn't want to be looked down upon by Mr Ji…
[LeetCode]785. Is Graph Bipartite? 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/is-graph-bipartite/description/ 题目描述: Given an undirected graph, return true if and only if it is bipartite. Re…
最近在准备找工作的算法题,刷刷LeetCode,以下是我的解题报告索引,每一题几乎都有详细的说明,供各位码农参考.根据我自己做的进度持续更新中......                              本文地址 LeetCode:Reverse Words in a String LeetCode:Evaluate Reverse Polish Notation LeetCode:Max Points on a Line LeetCode:Sort List LeetCode:Ins…
CF Round #600 (Div 2) 解题报告(A~E) A:Single Push 采用差分的思想,让\(b-a=c\),然后观察\(c\)序列是不是一个满足要求的序列 #include<bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int T, n; int a[maxn], b[maxn]; int c[maxn]; int main() { cin >> T; while(T--) { s…
题干 Bob is very interested in the data structure of a tree. A tree is a directed graph in which a special node is singled out, called the "root" of the tree, and there is a unique path from the root to each of the other nodes. Bob intends to colo…