算法练习
无
_xwj.
心灵鸡汤之天空飘来五个字——那都不是事。
展开
-
周总结-蓝桥2021
蓝桥杯的多了一个向左下走的次数和向右下走的次数相差不能超过1的条件,看似是变难了,实际上确实变简单了,因为这一个条件的存在,使得最后的结尾点只能是最后一层最中央的两个点。本题注意一下,由于n的数据范围很大,直接写while循环会超时,所以得先计算一下需要几周,在计算还需要几天。注意这个题的范围并不是89991231而是99991231,不明白。所以只要先正常dp,然后再输出那两个点中dp值较大的那个就行。先将所有因子存放在一个数组中,再遍历。原创 2023-04-10 09:52:35 · 171 阅读 · 0 评论 -
周总结-蓝桥2017和2018和2020
【代码】周总结-蓝桥2017和2018。原创 2023-04-10 09:40:13 · 146 阅读 · 0 评论 -
树的遍历 hdu 1710
hdu 1710#include <iostream>using namespace std;//已知先序后后序const int N=1010;int pre[N],in[N],post[N];int k;struct node{ int date; node *r,*l; node(int date,node *l=NULL,node *r=NULL):date(0),l(l),r(r){}};void creat(int l,int r,int原创 2022-05-14 23:30:59 · 85 阅读 · 0 评论 -
【二叉树的遍历】
#include using namespace std;struct node{char data;node *lc,*rc;};class BT{public:BT(){root=creat();}~BT(){release(root);}void preorder(){preorder(root);}void inorder(){inorder(root);}void postorder(){postorder(root);}void lev原创 2022-05-14 23:32:45 · 107 阅读 · 0 评论 -
后缀表达式求值
#include <iostream>using namespace std;stack<char> a;char str[105];char s[105];int Stack[60];int top = -1;int i,k = 0;//后缀表达式求值void Count(){ for(i=0; i<s.length(); i++) { if(s[i]==' ') continue;原创 2022-05-14 23:27:14 · 75 阅读 · 0 评论 -
【涂色问题】
#include <iostream>using namespace std;const int n=7;//三角板的个数//邻接矩阵,用来判断是否相邻const int data[n][n]={ {0,1,0,0,1,0,1}, {1,0,0,1,0,1,0}, {0,0,0,0,1,0,1}, {0,1,1,0,0,1,1}, {1,0,0,0,0,0,1}, {0,1,0,1,0,0,0}, {1,0,1,1,1,0,0原创 2022-05-14 23:25:58 · 165 阅读 · 0 评论 -
【简单哈希】
普通哈希和进阶哈希原创 2022-04-05 13:01:59 · 499 阅读 · 0 评论 -
【简单模拟】
奖学金 (简单模拟)原创 2022-04-02 21:04:33 · 56 阅读 · 0 评论 -
【约瑟夫问题——队列】
简单题 一题多解原创 2022-04-07 07:33:56 · 2473 阅读 · 0 评论 -
【反转链表】
【反转链表】(做题就要做得开心😎)原创 2022-04-04 13:24:37 · 860 阅读 · 0 评论 -
【动态规划基础1】
动态规划基础题,越简单的题越能总结规律。原创 2022-04-13 23:23:04 · 183 阅读 · 0 评论 -
【位运算题解3】
位运算3——中等的典型题原创 2022-04-05 20:50:51 · 661 阅读 · 0 评论 -
【简单二分查找模板】
【简单的二分查找题】原创 2022-04-02 20:59:18 · 387 阅读 · 0 评论 -
【简单队列和模拟】
简单的队列模拟题原创 2022-04-08 22:31:28 · 446 阅读 · 0 评论 -
【后缀表达式——栈】
简化的后缀表达式🍜原创 2022-04-06 08:09:38 · 1047 阅读 · 0 评论 -
【位运算题解2】
位运算2——比较详细的典型题原创 2022-04-04 16:45:36 · 624 阅读 · 0 评论 -
【简单贪心】
【简单贪心】原创 2022-04-03 14:09:41 · 187 阅读 · 1 评论 -
【位运算知识1】
位运算1——基础知识原创 2022-04-04 14:55:44 · 389 阅读 · 0 评论 -
【递归和分治算法】第三章
这里写目录标题递归斐波那契全排列整数划分分治策略选择问题输油管道问题半数集问题整数因子分解取余运算Big String递归斐波那契全排列整数划分分治策略选择问题输油管道问题半数集问题整数因子分解取余运算Big String...原创 2022-03-14 22:07:01 · 234 阅读 · 0 评论 -
【递归与递推】p1216
#include <iostream>using namespace std;//一开始我用一维数组存发现有点尴尬const int N=10005;int a[N][N],f[N][N];int n;int dfs(int x,int y){ if(x==n) return a[x][y]; if(f[x][y]) return f[x][y]; return f[x][y]=max(dfs(x+1,y),dfs(x+1,y+1))+a[x][y];}原创 2022-01-14 08:28:07 · 139 阅读 · 0 评论 -
广搜题解8.18
BFS简单题解题“Catch That Cow”poj3278深搜运用队列how:起点start固定,两种方式走到next,所以下一个点两种情况,不同于上一个题next是上下左右四个方向的点,so起点出队列时,两个对应的点进入队列。code:...原创 2021-08-18 01:24:38 · 138 阅读 · 0 评论 -
并查集题解8.3
并查集一级目录二级目录三级目录一级目录二级目录三级目录原创 2021-08-03 21:58:35 · 68 阅读 · 0 评论 -
字符串2 暑假day6-7(7.26)
字符串2KMPAC自动机后缀树和后缀数组KMPAC自动机后缀树和后缀数组原创 2021-07-26 22:53:58 · 54 阅读 · 0 评论 -
并查集题解8.7
并查集解题poj2236该题更注重并查集的应用与题目情景相结合有一定思考量(要有运用并查集的思维惯性)还需多看些题#include <iostream>using namespace std;const int maxn=1005;struct node{ int x; int y; int parent; int h; int f;//表示能不能合并}s[maxn];int n,d;void init(){ for(原创 2021-08-07 13:00:27 · 41 阅读 · 0 评论 -
复杂度分析
运行时间(复杂度分析)#include <iostream>#include<ctime>using namespace std;int main()//在main函数中,用clock()统计时间{ clock_t start,end; start=clock(); sunfa();//自定义算法 end=clock(); cout<<(double)(end-start)/CLOCKS_PER_SEC<<en原创 2021-08-14 14:48:42 · 62 阅读 · 0 评论 -
STL进阶使用 暑假day 1-2
STL——容器概述顺序式容器关联式容器概述顺序式容器关联式容器原创 2021-07-23 01:16:20 · 78 阅读 · 0 评论 -
广搜题解8.17
BFS&DFS一般用队列这种数据结构来具体实现BFS;对于DFS,运用递归实现最普遍,也可以用“栈”,两种在算法思想上一致。原创 2021-08-17 23:41:59 · 59 阅读 · 0 评论 -
假期学习总结+学习计划
假期学习总结一级目录二级目录三级目录一级目录二级目录三级目录原创 2021-08-02 21:17:00 · 85 阅读 · 0 评论 -
排列和组合 2
组合原创 2021-08-17 21:37:38 · 52 阅读 · 0 评论 -
2021-08-20
总结:看见搜索子莫名的畏惧,看了J题尝试按模板但真的毫无头绪,无语中,状态压缩还用到了位运算,头大,呜呜呜看到后面有双向搜索,和康托展开的题,先做这两道,起码还在认知范围内????就做这两道了,看多了自卑,前面做的题还需优化,像B题,其他方法提交一下加深印象,多看看这些题总比搜索好????。(抑郁,什么时候能变成大佬)...原创 2021-08-19 23:16:32 · 49 阅读 · 0 评论 -
假前做题整理 暑假day 3
6.1Codeforces Round #595 (Div. 3), problem: (C1) Good Numbers (easy version)https://codeforces.com/contest/1249/problem/C1题目意思是找到一个大于等于n的数,并且越小越好 然后满足那个数是由3的幂求和得到的 注意3的幂次只能存在一次,幂不能相同递归:#include<bits/stdc++.h>using namespace std;int t,n;int f(原创 2021-07-23 01:39:21 · 158 阅读 · 0 评论 -
VJ Runtime Error(运行错误)
VJ Runtime Error可能原因runtime error运行错误(代码运行不通过)可能原因:1.除数为02.数组越界(可能开小了,也可能边界问题)3.指针越界4.数组太大,超过栈的范围5.使用已释放的内存当有运行错误的提示时Runtime Error(ARRAY_BOUNDS_EXCEEDED) // array bounds exceed 数组越界Runtime Error(DIVIDE_BY_ZERO) //divisor is nil原创 2021-08-18 10:59:32 · 459 阅读 · 0 评论 -
Codeforces Round #739 (Div. 3)(F1补题)
Codeforces Round #739 (Div. 3)F1. Nearest Beautiful Number (easy version)code:(Test: #2, time: 1000 ms., memory: 42784 KB, exit code: -1, checker exit code: 0, verdict: TIME_LIMIT_EXCEEDED)#include <iostream>#include <set>#include<cstr原创 2021-08-19 01:27:49 · 112 阅读 · 0 评论 -
STL中的list的使用
STL中的list的使用list.earse()返回被删除迭代器的下一个迭代器list的删除有两种方法1. std::list< int> List; std::list< int>::iterator itList; for( itList = List.begin(); itList != List.end(); ) { if( WillDelete( *itList) ) itLis原创 2021-08-16 21:31:56 · 39 阅读 · 0 评论 -
Codeforces Round #739 (Div. 3)(D题)
div.3是我不配,D&E涉及知识缺陷,补补补原创 2021-08-20 00:37:26 · 60 阅读 · 0 评论 -
并查集练习题8.4
并查集简单题poj1611#include <iostream>using namespace std;const int maxn=30000+5;int s[maxn];int h[maxn];void init(int nn){ for(int i=0; i<nn; i++) { s[i]=i; h[i]=1; }}int find_s(int x){ return x==s[x]?x:find_原创 2021-08-04 23:32:35 · 86 阅读 · 1 评论 -
排列和组合 1
排列组合一级目录二级目录三级目录一级目录二级目录三级目录原创 2021-08-05 23:21:10 · 42 阅读 · 0 评论 -
字符串1 暑假day4-5
字符串字符串基本操作字符串哈希字典树KmpAC自动机后缀树和后缀数组字符串基本操作读取整个字符串gets()读取一个字符getchar()字符串哈希字典树KmpAC自动机后缀树和后缀数组原创 2021-07-24 22:34:25 · 69 阅读 · 0 评论 -
并查集题解8.5
并查集好题poj1703#include <iostream>using namespace std;const int maxn=100000+5;int s[maxn];int h[maxn];void init(){ for(int i=0; i<maxn; i++) { s[i]=0; h[i]=1; }}int find_s(int x){ return x==s[x]?x:find_s(s[原创 2021-08-05 23:11:55 · 50 阅读 · 0 评论 -
【周总结】暑假1
周总结深搜原创 2022-03-05 19:04:19 · 109 阅读 · 0 评论