
竞赛
文章平均质量分 70
Keep--Silent
这个作者很懒,什么都没留下…
展开
-
给逆序对数求原数组
给逆序对数求原数组原创 2022-06-16 22:09:56 · 205 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1057 Stack
PAT (Advanced Level) Practice 1057 Stack树状数组查找中位数原创 2022-06-05 10:11:19 · 181 阅读 · 0 评论 -
红黑树操作
前言AVL的插入和删除操作,会频繁地调整全树的结构,代价较大。因此,在AVL的平衡标准上放宽条件,引入红黑树。目录性质定义推论插入情况一情况二情况三情况四情况五性质定义①每个结点是红色或者黑色②根结点是黑色。③每个叶子结点都是黑色的空结点(NUUL结点)。④不存在两个相邻的红节点。(即红节点之父和红节点之子必是黑)⑤从任一结点到其每个叶子的所有路径都包含相同数目的黑色结点。推论①从根节点到叶节点的最长路径不超过最短路径的两倍②有n个内部结点的红黑树的高度h≤2log2(n原创 2022-04-03 20:50:45 · 547 阅读 · 0 评论 -
动态规划之矩阵连乘
核心:if i>=ji>=ji>=j: dp[i][j]=0dp[i][j]=0dp[i][j]=0else: dp[j][j]=max(dp[i][k]+dp[k+1][j]+p[i−1]∗p[k]∗p[j]dp[j][j]=max(dp[i][k]+dp[k+1][j]+p[i-1]*p[k] *p[j]dp[j][j]=max(dp[i][k]+dp[k+1][j]+p[i−1]∗p[k]∗p[j] for k in (i,j) )))class MatrixMultipli原创 2021-12-12 10:29:17 · 749 阅读 · 0 评论 -
深度优先搜索
深度优先搜索:Depth First Search本文讲解以DFS解决校选题深度优先搜索常常复杂度较大,所以需要根据题目的题意进行适当剪枝。目录中档题-2 勋总的幂集 (15 分)中档题-5 LIS (20 分)中档题-6 勋总的求偶日记 (25 分)压轴题-1 贝贝的数组划分 (30 分)压轴题-2 别装13 (30 分)中档题-2 勋总的幂集 (15 分)链接dfs:15分中档题-5 LIS (20 分)链接dfs:2分dfs剪枝后:8分中档题-6 勋总的求偶日记 (2原创 2021-11-20 12:45:45 · 763 阅读 · 0 评论 -
讲解STL
目录queuestackstringpriority_queuevectorsetmapmap-string,intmap-vec,intvector-vectoriteratorqueue队列int x,y,n;queue<int>q;q.push(12); q.push(13); n=q.size();//n=2;x=q.front();q.pop();y=q.front();stack栈stack<int> s;q.push(12); q.pus原创 2021-11-12 10:31:10 · 1626 阅读 · 0 评论 -
1101 Quick Sort (25 分) st表
题目链接1101 Quick Sort (25 分)There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the pivot are moved to its left and those larger than the原创 2021-09-09 10:04:21 · 114 阅读 · 0 评论 -
1068 Find More Coins (30 分)
Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments. However, there was a special requirement of the payment: for eac原创 2021-09-06 10:41:01 · 287 阅读 · 0 评论 -
1010 Radix (25 分) 暴力枚举
1010 Radix (25 分)Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number.Now for any pair of positive integers N1 and N2, your task is to find th原创 2021-09-06 10:15:47 · 190 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1049 Counting Ones (30 分)
The task is simple: given any positive integer N, you are supposed to count the total number of 1’s in the decimal form of the integers from 1 to N. For example, given N being 12, there are five 1’s in 1, 10, 11, and 12.Input Specification:Each input fil原创 2021-08-22 14:25:31 · 97 阅读 · 0 评论 -
1045. Favorite Color Stripe (30)-PAT甲级真题
Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwanted pieces and sewing the remaining parts together to form her favorite color stripe.It is said原创 2021-08-22 12:21:34 · 160 阅读 · 0 评论 -
最长公共序列和
(为了水博客而写)找出公式:实现#include<iostream>#include<algorithm>using namespace std;typedef long long ll;#define SIZE (100+10)int dp[30][30];int main() { string s; string s1=" caebdaaf"; string s2=" aa"; int j,i; for(i=1; i<s1.size(); i++原创 2021-07-13 16:29:01 · 101 阅读 · 0 评论 -
最长非递减子序列
给定一个数组num[],求最长非递减子序列。解决:用一个数组ans来存这个子序列关键:怎么更新这个数组?扫一遍num[]假设当前扫到num[i],更新操作:①如果num[i]大于等于ans最后一个数(或者ans为空),那么ans在末尾插入num[i]②否则的话,在ans[]中,找到第一个大于num[i]的数,将其更新为num[i]。如数组num[]={4,2,6,3,5,2,2,2};i = 0, ans[]={4};i = 1, ans[]={2};i = 2, ans[]={原创 2021-07-13 15:42:08 · 554 阅读 · 0 评论 -
第十二届蓝桥省赛C/C++b组填空题解析
声明:以下答案仅代表个人答案,不保证正确。如有蒙对,万分荣幸填空目录试题 A: 空间题目解析试题 B: 卡片题目解析试题 C: 直线题目解析试题 D: 货物摆放题目解析试题 E: 路径题目解析试题 A: 空间题目【问题描述】小蓝准备用 256MB 的内存空间开一个数组,数组的每个元素都是 32 位二进制整数,如果不考虑程序占用的空间和维护内存需要的辅助空间,请问256MB 的空间可以存储多少个 32 位二进制整数?解析答案:671088641MB=1024kb1kb=1024b1b=原创 2021-04-19 20:03:07 · 8695 阅读 · 14 评论