上一页 1 ··· 63 64 65 66 67
摘要: 归并排序 const int N=1e5+10; int a[N],b[N]; int n; void merge_sort(int l,int r) { if(l>=r) return; int mid=l+r>>1; merge_sort(l,mid); merge_sort(mid+1,r); 阅读全文
posted @ 2020-08-25 17:26 Dazzling! 阅读(78) 评论(0) 推荐(0) 编辑
摘要: 快速排序 const int N=1e5+10; int a[N]; int n; void quick_sort(int l,int r) { if(l>=r) return; int i=l-1,j=r+1,x=a[l+r>>1]; while(i<j) { while(a[++i]<x); w 阅读全文
posted @ 2020-08-25 17:18 Dazzling! 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 第k个数 const int N=1e5+10; int a[N]; int n,k; int quick_sort(int l,int r,int k) { if(l>=r) return a[l]; int i=l-1,j=r+1,x=a[l+r>>1]; while(i<j) { while( 阅读全文
posted @ 2020-08-25 17:13 Dazzling! 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 分析: 题目告诉了我们一种规则由a数组变成b数组。如 A={5,1,4,2,3} ,k=2; 当我们求bi时,先到a数组找i=aj;看a1-aj中有几个数是满足ax<=i+k的,满足的数的个数即为bi的值。 求b1时,先找到1在a数组中得位置,得到1左边的数 5;有5>=1+2;所以b1=1; 求b 阅读全文
posted @ 2020-02-17 22:35 Dazzling! 阅读(164) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <algorithm> #include <cstdio> using namespace std; const int N = 500010; typedef long long ll; struct node { int to, nex; 阅读全文
posted @ 2020-02-17 21:48 Dazzling! 阅读(204) 评论(0) 推荐(0) 编辑
摘要: https://codeforces.ml/problemset/problem/1129/A2 对于一个车站,有x个糖果,至少要经过这个车站x次,因为每次都只能装一颗,那就意味着至少要跑x-1圈,那么在一圈中肯定已经经过了要卸货的车站,因为一圈嘛,所有的车站都经过了一遍,所以对于一个车站,再次经过 阅读全文
posted @ 2020-02-14 13:00 Dazzling! 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 一个字符串有许多子序列,比如字符串abcfgbda,它的子序列有a、bfg、bfgbd,在这些子序列中肯定有回文字符串。现在要对任意字符串求其最长的回文子序列。注意,本文不是解决最长回文子串,回文子串是连续的,回文子序列是不连续的。 字符串abcfgbda的最长回文子序列为abcba,长度为5。 输 阅读全文
posted @ 2020-02-11 20:40 Dazzling! 阅读(398) 评论(0) 推荐(0) 编辑
摘要: 主要内容: 1、什么是回文? 2、字符子串和字符子序列的区别 3、最长回文子序列的思路和代码 4、回文子序列个数的思路和代码 1、什么是回文palindrome? 回文指的是正读和反读都一样的字符串,如aba,abba等 2、字符子串和字符子序列的区别 字符字串指的是字符串中连续的n个字符;如pal 阅读全文
posted @ 2020-02-11 20:01 Dazzling! 阅读(587) 评论(0) 推荐(0) 编辑
上一页 1 ··· 63 64 65 66 67