摘要: 1 #include<iostream> 2 #include<vector> 3 using namespace std; 4 //n-节点数 5 //m-边的数 6 //给一幅图,判断是否存在环 7 int find_root(int x, vector<int>&parent) { 8 if 阅读全文
posted @ 2020-09-19 15:15 人间有味_是清欢 阅读(288) 评论(0) 推荐(0) 编辑
摘要: 1 #include<iostream> 2 using namespace std; 3 //n-节点数 4 //m-边的数 5 //p-测试数 6 //给一幅图,判断两个点之间是否存在路径 7 8 int root[10001], n, m, p; 9 int find(int x) { 10 阅读全文
posted @ 2020-09-19 14:49 人间有味_是清欢 阅读(279) 评论(0) 推荐(0) 编辑
摘要: 相关题目:文件的编译顺序 方法:利用邻接链表的深度优先搜索 1 #include <algorithm> 2 #include <iostream> 3 #include <vector> 4 5 int number_of_vertices, 6 number_of_edges; // For n 阅读全文
posted @ 2020-09-15 14:16 人间有味_是清欢 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 1 // C++ program to implement Prim's Algorithm 2 #include <iostream> 3 #include <queue> 4 #include <vector> 5 6 using PII = std::pair<int, int>; 7 8 i 阅读全文
posted @ 2020-09-15 10:25 人间有味_是清欢 阅读(161) 评论(0) 推荐(0) 编辑
摘要: priority_queue优先级的定义:两个数a,b,如果返回true,则a的优先级小于b的优先级 less:返回a<b,则如果a小,返回true,a的优先级小,a在后,为大根堆 greater:返回a>b,如果a小,则返回false,a的优先级大,a在前,为小根堆 阅读全文
posted @ 2020-09-15 09:22 人间有味_是清欢 阅读(876) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2020-09-11 19:59 人间有味_是清欢 阅读(208) 评论(0) 推荐(0) 编辑
摘要: 根据《算法导论》上的伪代码修改,书上的字符串索引从1开始,需要修改为从0开始 1 class Solution { 2 public: 3 int strStr(string haystack, string needle) { 4 int sz1 = haystack.size(), sz2 = 阅读全文
posted @ 2020-09-06 13:38 人间有味_是清欢 阅读(120) 评论(0) 推荐(0) 编辑
摘要: a、b、c三个物品,两个可以换另一个,三个可以换一个奖品,求最多能换多少个奖品 1 class Solution { 2 public: 3 int numberofprize(int a, int b, int c) { 4 int lo = 0, hi = 1E9; 5 int ret = 0; 阅读全文
posted @ 2020-09-06 13:30 人间有味_是清欢 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 1 int main() { 2 vector<int> nums{ 5,4,2,6,7,3,9 }; 3 int length = nums.size(); 4 5 stack<vector<int>>sk1; 6 vector<int>rightFirstMax(length, 0); 7 fo 阅读全文
posted @ 2020-09-06 12:29 人间有味_是清欢 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 解决方法:把py文件属性设置为可执行。 阅读全文
posted @ 2020-01-08 11:05 人间有味_是清欢 阅读(2158) 评论(0) 推荐(0) 编辑