Sequence one
algorithm. When you want to solve a problem by using the search
method, try to cut is very important.
Now give you a number sequence, include n (<=1000) integers,
each integer not bigger than 2^31, you want to find the first P
subsequences that is not decrease (if total subsequence W is
smaller than P, than just give the first W subsequences). The order
of subsequences is that: first order the length of the subsequence.
Second order the sequence of each integer’s position in the initial
sequence. For example initial sequence 1 3 2 the total legal
subsequences is 5. According to order is {1}; {3}; {2}; {1,3};
{1,2}. {1,3} is first than {1,2} because the sequence of each
integer’s position in the initial sequence are {1,2} and {1,3}.
{1,2} is smaller than {1,3}. If you also can not understand ,
please see the sample carefully.
cases.
Each test case include, first two integers n, P. (1
according to the problem description. And at the end of each case
follow a empty line.
5
2
6
2
100
2
3
2
3
2
2
3
3
2
3
2
printf(i?" %d":"%d",pot[i]);
return false;//如果这个数在前面出现过了就不能用了
return;//大于p的就不需要搜了
ans++;
flag=true;
printf(len);//将数组输出
return;
if((cur&&pot[cur-1]<=pos[i])||!cur)
//1 不是第一位的并且可以用这个数
//2 是第一位的
{
if(!cur&&!check(-1,i))//第0位没法比较这个数在前没出现没出现过
//所以只能用-1来比较
continue;
if(cur&&!check(op[cur-1],i))//这才能比较
continue;
pot[cur]=pos[i];
op[cur]=i;//记录到第几位了
dfs(cur+1,i+1);//不是从t+1开始搜的,而是从你找到这个数的下一位开始搜的
}
stdin);
while(scanf("%d%d",&n,&p)!=EOF)
memset(pos,0,sizeof pos);
memset(pot,0,sizeof pot);
for(int i=0;i
scanf("%d",&pos[i]);
ans=0;
for(int i=1;i
{
flag=false;
len=i;
dfs(0,0);
if(ans>=p||!flag) break;
}
printf("\n");
Sequence one的更多相关文章
- oracle SEQUENCE 创建, 修改,删除
oracle创建序列化: CREATE SEQUENCE seq_itv_collection INCREMENT BY 1 -- 每次加几个 STA ...
- Oracle数据库自动备份SQL文本:Procedure存储过程,View视图,Function函数,Trigger触发器,Sequence序列号等
功能:备份存储过程,视图,函数触发器,Sequence序列号等准备工作:--1.创建文件夹 :'E:/OracleBackUp/ProcBack';--文本存放的路径--2.执行:create or ...
- DG gap sequence修复一例
环境:Oracle 11.2.0.4 DG 故障现象: 客户在备库告警日志中发现GAP sequence提示信息: Mon Nov 21 09:53:29 2016 Media Recovery Wa ...
- Permutation Sequence
The set [1,2,3,-,n] contains a total of n! unique permutations. By listing and labeling all of the p ...
- [LeetCode] Sequence Reconstruction 序列重建
Check whether the original sequence org can be uniquely reconstructed from the sequences in seqs. Th ...
- [LeetCode] Binary Tree Longest Consecutive Sequence 二叉树最长连续序列
Given a binary tree, find the length of the longest consecutive sequence path. The path refers to an ...
- [LeetCode] Verify Preorder Sequence in Binary Search Tree 验证二叉搜索树的先序序列
Given an array of numbers, verify whether it is the correct preorder traversal sequence of a binary ...
- [LeetCode] Longest Consecutive Sequence 求最长连续序列
Given an unsorted array of integers, find the length of the longest consecutive elements sequence. F ...
- [LeetCode] Permutation Sequence 序列排序
The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the p ...
- Leetcode 60. Permutation Sequence
The set [1,2,3,-,n] contains a total of n! unique permutations. By listing and labeling all of the p ...
随机推荐
- StringBuffer和String的相互转换
1:用法: * A:String -- >StringBuffer * a:通过构造方法 * b:通过append()方法 * B:StringBuffer --> String * a: ...
- Apache Spark 2.2.0 中文文档 - SparkR (R on Spark) | ApacheCN
SparkR (R on Spark) 概述 SparkDataFrame 启动: SparkSession 从 RStudio 来启动 创建 SparkDataFrames 从本地的 data fr ...
- Pro Flight YOKE 设备键位映射踩过的坑
背景 VR游戏项目.街机游戏项目7月阶段版本快要结束了,考虑到带有键鼠外设显得逼格比较Low,所以决定采用"高大上"的专业设备来进行游戏操作. 需求 需要将键盘鼠标操作的18个键位 ...
- UI自动化测试(二)浏览器操作及对元素的定位方法(xpath定位和css定位详解)
Selenium下的Webdriver工具支持FireFox(geckodriver). IE(InternetExplorerDriver).Chrome(ChromeDriver). Opera( ...
- Redis 的安装与使用
环境:CentOS 6.6 Redis 版本:redis-3.0 (考虑到 Redis3.0 在集群和性能提升方面的特性,rc 版为正式版的候选版,而且很快就出正式版) 安装目录:/usr/local ...
- 【NOIP】OpenJudge - 15-02:财务管理
#include<stdio.h>//财务管理 int main() { ]={},sum=,ave=; ;i<=;i++) { scanf("%f",& ...
- 退出psql时,报psql_history的错
数据库版本:Enterprisedb 9.2(postgreSQL) 错误如下所示: postgres=# exitcould not save history to file "/opt/ ...
- css3弹性盒模型flex快速入门与上手1
一.什么是flex? flex是css3中引入的一种布局方式,可以非常灵活高效控制元素的排列与对齐方式,大多人称之为弹性布局. 二.怎么使用flex? 任何一个容器都可以指定为flex布局 #box ...
- Lucene介绍与入门使用
Lucene简介 Lucene是apache软件基金会4 jakarta项目组的一个子项目,是一个开放源代码的全文检索引擎工具包,但它不是一个完整的全文检索引擎,而是一个全文检索引擎的架构,提供了完整 ...
- zoj2818 Root of the Problem 简单数学 开方
Root of the Problem Time Limit: 2 Seconds Memory Limit: 65536 KB Given positive integers B and ...