problem 给出 \(n\) 个互不包含的字符串,要求你求出一个最短的字符串 \(S\),使得这 \(n\) 个字符串在 \(S\) 中总共至少出现 \(m\) 次,问 \(S\) 最短是多少。 solution 我们首先转化题意: 有 \(n\) 个点,两个点 \(i,j\) 之间的权值为将第 ...
分类:
其他好文 时间:
2020-12-02 11:59:30
阅读次数:
3
108. 将有序数组转换为二叉搜索树 Difficulty: 简单 将一个按照升序排列的有序数组,转换为一棵高度平衡二叉搜索树。 本题中,一个高度平衡二叉树是指一个二叉树_每个节点 _的左右两个子树的高度差的绝对值不超过 1。 示例: 给定有序数组: [-10,-3,0,5,9], 一个可能的答案是 ...
分类:
编程语言 时间:
2020-12-01 12:09:01
阅读次数:
6
题目 题目链接:https://www.ybtoj.com.cn/contest/62/problem/3 思路 可以看做有多少个 $1\sim n$ 的排列满足对于一条路径 \(u\to v\),\(u\) 在序列中的位置一定在 \(v\) 在序列中的位置的前面。 设 \(f[x][i]\) 表示 ...
分类:
其他好文 时间:
2020-11-30 15:20:42
阅读次数:
2
https://pintia.cn/problem-sets/1218774283169423360/problems/1218774532776648715 #include <cstdio> #include <iostream> #include <algorithm> #include <s ...
分类:
其他好文 时间:
2020-11-27 11:32:22
阅读次数:
6
https://www.luogu.com.cn/problem/P3366 1 #define IO std::ios::sync_with_stdio(0) 2 #include <bits/stdc++.h> 3 #define pb push_back 4 using namespace s ...
分类:
其他好文 时间:
2020-11-26 15:24:23
阅读次数:
48
problem: 给你n个数字,和m个查询. 将[l,r]之间数第一次出现的位置信息弄成一个新的数组,然后找出其中k/2大的数.(k为位置的数量) #include<bits/stdc++.h> using namespace std; const int maxn=2e5+100; const i ...
分类:
其他好文 时间:
2020-11-26 14:12:20
阅读次数:
3
#include<bits/stdc++.h> #define ll long long #define N 100015 #define rep(i,a,n) for (int i=a;i<=n;i++) #define per(i,a,n) for (int i=n;i>=a;i--) #def ...
分类:
其他好文 时间:
2020-11-25 12:45:31
阅读次数:
4
https://codeforces.ml/contest/888/problem/G struct TrieNode { int cnt; int num; int nxt[2]; void Init() { cnt = 0; num = 0; memset(nxt, 0, sizeof(nxt) ...
分类:
其他好文 时间:
2020-11-24 12:58:41
阅读次数:
10
HDU2040 亲和数 题目链接 Problem Description 古希腊数学家毕达哥拉斯在自然数研究中发现,220的所有真约数(即不是自身的约数)之和为: 1+2+4+5+10+11+20+22+44+55+110=284。 而284的所有真约数为1、2、4、71、 142,加起来恰好为22 ...
分类:
其他好文 时间:
2020-11-24 12:32:09
阅读次数:
8
给定一个只包括 '(',')','{','}','[',']' 的字符串,判断字符串是否有效。 有效字符串需满足: 左括号必须用相同类型的右括号闭合。 左括号必须以正确的顺序闭合。 注意空字符串可被认为是有效字符串。 示例 1: 输入: "()" 输出: true 示例 2: 输入: "()[]{} ...
分类:
其他好文 时间:
2020-11-24 12:14:38
阅读次数:
7