cf340D Bubble Sort Graph
link:http://codeforces.com/problemset/problem/340/D
感觉很好的一道题目。
认真思考,发现,逆序的数字对一定有边相连。所以,题目要求没有边相连的最大的集合的点的个数,其实就是找原来的序列的最长上升子序列!
/*
* Filename: tourist.cpp
* Created: 09/01/2013 09:07:05 AM
* Author: liuxueyang (lxy), zypz457@sina.com
* Organization: Hunnan University
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <queue>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <functional>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#include <ctime>
#include <iterator>
const int INF = 0x3f3f3f3f;
;
using namespace std;
];
int main ( int argc, char *argv[] )
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
ios::sync_with_stdio(false);
int n;
while (~scanf("%d", &n)) {
touch[] = -;
;
; i < n; ++i) {
scanf("%d", &tmp);
if (tmp > touch[top]) {
touch[++top] = tmp;
} else {
, touch++top, tmp) - touch;
touch[pos] = tmp;
}
}
printf("%d\n", top);
}
return EXIT_SUCCESS;
} /* ---------- end of function main ---------- */
好几天了,还是补上题解吧。
嗨,中村。
cf340D Bubble Sort Graph的更多相关文章
- [CF340D]Bubble Sort Graph/[JZOJ3485]独立集
题目大意: 给你一个序列,对序列中所有逆序对之间连一条边,问图中最大独立集为多大,有哪些点一定在最大独立集中. 思路: 在纸上画一下发现最大独立集一定是元序列的一个LIS,最大独立集必经点就是所有LI ...
- Codeforces Round #198 (Div. 2) D. Bubble Sort Graph (转化为最长非降子序列)
D. Bubble Sort Graph time limit per test 1 second memory limit per test 256 megabytes input standard ...
- codeforces 340D Bubble Sort Graph(dp,LIS)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Bubble Sort Graph Iahub recently has lea ...
- Bubble Sort Graph CodeForces - 340D || 最长不下降/上升子序列
Bubble Sort Graph CodeForces - 340D 题意: 给出一个n个数的数列,建一个只有n个结点没有边的无向图,对数列进行冒泡排序,每交换一对位置在(i,j)的数在点i和点j间 ...
- 【Codeforces 340D】Bubble Sort Graph
[链接] 我是链接,点我呀:) [题意] 让你根据冒泡排序的规则 建立一张图 问你这张图的最大独立子集的大小 [题解] 考虑a[i]会和哪些点连边? 必然是在a[i]左边且比它大的数字以及在a[i]右 ...
- Java中的经典算法之冒泡排序(Bubble Sort)
Java中的经典算法之冒泡排序(Bubble Sort) 神话丿小王子的博客主页 原理:比较两个相邻的元素,将值大的元素交换至右端. 思路:依次比较相邻的两个数,将小数放在前面,大数放在后面.即在第一 ...
- Bubble Sort (5775)
Bubble Sort Problem Description P is a permutation of the integers from 1 to N(index starting from ...
- Bubble Sort [ASM-MIPS]
# Program: Bubble sort # Language: MIPS Assembly (32-bit) # Arguments: 5 unordered numbers stored in ...
- HDU 5775 Bubble Sort(冒泡排序)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
随机推荐
- Sprint(第七天11.20)
燃尽图
- Pycharm使用问题# 内部Terminal
1.Windows XP并不支持内部Terminal
- nginx location配置
nginx location配置 location在nginx中起着重要作用,对nginx接收到的请求字符串进行处理,如地址定向.数据缓存.应答控制.代理转发等location语法location ...
- 使用sublime时报编码错误
在执行Python脚本时报如下错误: UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-78: ordin ...
- Eclipse 常用用法
搞了很多年的.NET, 最近开始搞Eclipse. 刚开始使用 Eclipse, 发现 Eclipser 远没有Visual Stuido 强大. 所以先把Eclipse常用的用法总结 ...
- R语言apply函数族笔记
为什么用apply 因为我是一个程序员,所以在最初学习R的时候,当成“又一门编程语言”来学习,但是怎么学都觉得别扭.现在我的看法倾向于,R不是一种通用型的编程语言,而是一种统计领域的软件工具.因此,不 ...
- Fireeye火眼公司发布报告,评论中国网络间谍活动
2013年10月2日,Fireeye火眼公司发布报告,评论中国网络间谍活动-Fireeye(美 国火眼公司)发布报告<世界网络大战:理解网络攻击背后的国家意图>(World War C: ...
- hdu 4747 Mex
http://acm.hdu.edu.cn/showproblem.php?pid=4747 设我们输入的数组为 a[],我们需要从 1 到 n 遍历, 假设遍历到 i 时, 遍历的过程中用b[j]表 ...
- Android Camera进行拍照
Android应用提供了Camera来控制拍照,使用Camera进行拍照的步骤: 1.调用Camera的open()方法打开相机. 2.调用Camera的getParameters()方法获取拍照参数 ...
- 黑马程序员——OC语言 核心语法 (3)
Java培训.Android培训.iOS培训..Net培训.期待与您交流! (以下内容是对黑马苹果入学视频的个人知识点总结) (一)分类Category 1) 基本用途 如何在不改变原来类模型的前提下 ...