题目大意: 给出个点,n为偶数,询问两个完全没有交集的匹配q和p。 一方面使得n个点两两互相匹配,一方面使得匹配的权值和最小 分析: 因为n是偶数,所以可以考虑将n个数分配到不同的长度为偶数的环中,对于排列q和排列p,只需要在偶环中交换一下位置就好。 但这个偶环的长度必须要大于2,因为如果长度为2, ...
分类:
其他好文 时间:
2020-07-24 21:58:55
阅读次数:
72
>>>dict() # 创建空字典 {} >>> dict(a='a', b='b', t='t') # 传入关键字 {'a': 'a', 'b': 'b', 't': 't'} >>> dict(zip(['one', 'two', 'three'], [1, 2, 3])) # 映射函数方式来构 ...
分类:
其他好文 时间:
2020-07-24 19:10:00
阅读次数:
67
class Solution { public int candy(int[] ratings) { int n = ratings.length; int[] arr = new int[n]; Arrays.fill(arr,1); // 先每人分一个 for(int i = 1; i < n; ...
分类:
其他好文 时间:
2020-07-24 19:04:42
阅读次数:
61
二分查找 #include<bits/stdc++.h> using namespace std; const int maxn = 2e5+5; long long a[maxn], b[maxn]; long long getKth(int k, int lo1, int hi1, int lo ...
分类:
其他好文 时间:
2020-07-23 23:22:49
阅读次数:
76
pip安装 pip install pytest-html 编写脚本 import pytest class TestClass(object): def test_one(self): x = "this" assert 'h' in x def test_two(self): x = "hell ...
分类:
其他好文 时间:
2020-07-23 16:50:29
阅读次数:
121
目录 大纲概述 数据集合 数据处理 预训练word2vec模型 一、大纲概述 文本分类这个系列将会有8篇左右文章,从github直接下载代码,从百度云下载训练数据,在pycharm上导入即可使用,包括基于word2vec预训练的文本分类,与及基于近几年的预训练模型(ELMo,BERT等)的文本分类。... ...
分类:
其他好文 时间:
2020-07-22 23:31:28
阅读次数:
91
1.Redis支持的数据类型? Redis支持五种数据类型:string(字符串),hash(哈希),list(列表),set(集合)及zset(sorted set:有序集合)。 2.什么是Redis持久化?Redis有哪几种持久化方式?优缺点是什么? redis提供两种方式进行持久化,一种是RD ...
分类:
其他好文 时间:
2020-07-22 20:13:10
阅读次数:
54
地址 https://leetcode-cn.com/problems/xuan-zhuan-shu-zu-de-zui-xiao-shu-zi-lcof/ https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array-i ...
分类:
编程语言 时间:
2020-07-22 11:21:34
阅读次数:
62
在c++中检查字符串是否包含另一串字符串,这个本来是我做过的一个算法题,不过最近刚好有个需求让我想到了这个题,就在此记录一下! 使用std::string::findfunction string str ("There are two needles in this haystack."); st ...
分类:
编程语言 时间:
2020-07-22 02:02:45
阅读次数:
79
对于这道题,可以想想对于每个b[i],a[i]中可选的位置的区间在哪,这样只要找到区间,就能知道当前可以选那几个位置断开 b[1]的开头肯定是1号位,而我们发现如果对后缀求一下后缀的最小值,这样就天然满足题目条件,我们用一个map存一下答案,就能知道b[i]是最小值的区间是哪些 因为b是单调递增的数 ...
分类:
其他好文 时间:
2020-07-22 02:00:03
阅读次数:
62