03 2020 档案
摘要:在求解欧拉回路的问题中我们可以采用fleury算法。 然而在进行算法竞赛时,如果只是求欧拉回路我们可以采用DFS进行实现,需要注意的小细节时在输出边时需要在回溯阶段逆向输出因为遇到 1->2->3->2->1这种图会出现走死路情况 来看道例题: UVA10054 #include <bits/std
阅读全文
摘要:以蓝书为学习参考,进行的栈的学习 例题1: 实现一个栈,支持Push,Pop和GetMin(查询栈中最小的值)在O(1)完成 算法实现思路:建立两个栈,A存原本的数据,B存以栈底开头的每段数据的最小值 Push(X),在A中插入X,在B中插入min(B的栈顶数据,X)。执行GetMin只需要输出B.
阅读全文
摘要:class Solution { public: vector<string> wordBreak(string s, vector<string>& wordDict) { if (m.count(s)) return m[s]; //判断map中有没有s if (s.empty()) retur
阅读全文
摘要:1. Sample Input 6 -2 11 -4 13 -5 -2 10 -10 1 2 3 4 -5 -23 3 7 -21 6 5 -8 3 2 5 0 1 10 3 -1 -5 -2 3 -1 0 -2 0 Sample Output 20 11 13 10 1 4 10 3 5 10 1
阅读全文
摘要:最终刷题太多了博客思路慢慢更新 1.利用havel定理判断可不可以简单图化的一道好题 Sample Input 3 7 4 3 1 5 4 2 1 6 4 3 1 4 2 0 6 2 3 1 1 2 1 Sample Output YES 0 1 0 1 1 0 1 1 0 0 1 1 0 0 0
阅读全文
摘要:#include <iostream> #include <cmath> using namespace std; double calcualateCircle(double r = 0) { return acos(-1) * r * r; } double calcualateRectangl
阅读全文
摘要:1. Sample Input 9 5 2 1 5 2 1 5 2 1 4 1 2 3 4 0 Sample Output 6 5 #include <bits/stdc++.h> using namespace std; typedef long long ll; int a[100]; bool
阅读全文
摘要:1. Sample Input 6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#
阅读全文
摘要:匈牙利算法 匈牙利算法是一种在多项式时间内求解任务分配问题的组合优化算法 该算法是求解二分图的完全匹配问题 建图:把行号放左边点集,列号放在右边点集。 关键是求该二分图的最小边覆盖点集使得每条边都被至少一个点覆盖。 算法模板: //使用bfs实现 int dfs(int e) { for(int i
阅读全文