题意:给一串由n个数字组成的字符串,选择其中一个区间进行翻转,要求翻转后该字符串的最长非降子序列长度最长,输出这个最长非降子序列的长度以及翻转的区间的左右端点 #include<bits/stdc++.h> using namespace std; typedef long long ll; ; ; int n, a[maxn], dp[maxn][maxm], b[maxm]; int ans, ansl, ansr, l, r, cnt; int al[maxn][maxm], ar[ma
题目链接 Problem Description We are all familiar with sorting algorithms: quick sort, merge sort, heap sort, insertion sort, selection sort, bubble sort, etc. But sometimes it is an overkill to use these algorithms for an almost sorted array. We say an a
D. Once Again... You are given an array of positive integers a1, a2, ..., an × T of length n × T. We know that for any i > n it is true that ai = ai - n. Find the length of
Constructing Roads In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 27358 Accepted Submission(s): 7782 Problem Description JGShining's kingdom consists of 2n(n is no mor
D. Bubble Sort Graph time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Iahub recently has learned Bubble Sort, an algorithm that is used to sort a permutation with n elements a1, a2, ..., an
Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. The longest uncommon subsequence is defined as the longest subsequence of one of these strings and this subsequence should not be any subseq
之前讲到过求最长非降子序列的O(N^2)解法. 链接 这次在原来的基础上介绍一下N*logN解法. 该解法主要是维护一个数组minValue,minValue[i]表示最长上身子序列长度为i的数的最小值. 代码如下: #include <iostream> using namespace std; #define inf (1<<29) const int maxn = 100100; int n, a[maxn], minValue[maxn]; int getIndex(int
题目: 求一个数组的最长递减子序列比 , 如随机生成一组序列 {8,9,6,3,6,2,3,4} 求得最长递减序列 {9,8,6,4,3,2} list=[3,3,3,3,6,2,3,4] //冒泡排序 n=len(list) for i in range(0,n-2): for k in range(0,n-1): if list[k+1]>list[k]: list[k+1],list[k]=list[k],list[k+1] print(list) result=[] for i in
Given a list of strings, you need to find the longest uncommon subsequence among them. The longest uncommon subsequence is defined as the longest subsequence of one of these strings and this subsequence should not be any subsequence of the other stri
B. Once Again... time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given an array of positive integers a1, a2, ..., an × T of length n × T. We know that for any i > n it is true that
题目链接: http://acm.hust.edu.cn/vjudge/problem/356795 Racing Gems Time Limit: 3000MS 问题描述 You are playing a racing game. Your character starts at the x axis (y = 0) and proceeds up the race track, which has a boundary at the line x = 0 and another at x
#include <iostream> #include <vector> using namespace std; int main() { //输入 int tmp; vector<int> input; while (cin >> tmp) { input.push_back(tmp); if (cin.get() == '\n') { break; } } for (vector<int>:: iterator it = input.be