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的更多相关文章

  1. [CF340D]Bubble Sort Graph/[JZOJ3485]独立集

    题目大意: 给你一个序列,对序列中所有逆序对之间连一条边,问图中最大独立集为多大,有哪些点一定在最大独立集中. 思路: 在纸上画一下发现最大独立集一定是元序列的一个LIS,最大独立集必经点就是所有LI ...

  2. 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 ...

  3. codeforces 340D Bubble Sort Graph(dp,LIS)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud  Bubble Sort Graph Iahub recently has lea ...

  4. Bubble Sort Graph CodeForces - 340D || 最长不下降/上升子序列

    Bubble Sort Graph CodeForces - 340D 题意: 给出一个n个数的数列,建一个只有n个结点没有边的无向图,对数列进行冒泡排序,每交换一对位置在(i,j)的数在点i和点j间 ...

  5. 【Codeforces 340D】Bubble Sort Graph

    [链接] 我是链接,点我呀:) [题意] 让你根据冒泡排序的规则 建立一张图 问你这张图的最大独立子集的大小 [题解] 考虑a[i]会和哪些点连边? 必然是在a[i]左边且比它大的数字以及在a[i]右 ...

  6. Java中的经典算法之冒泡排序(Bubble Sort)

    Java中的经典算法之冒泡排序(Bubble Sort) 神话丿小王子的博客主页 原理:比较两个相邻的元素,将值大的元素交换至右端. 思路:依次比较相邻的两个数,将小数放在前面,大数放在后面.即在第一 ...

  7. Bubble Sort (5775)

    Bubble Sort Problem Description   P is a permutation of the integers from 1 to N(index starting from ...

  8. Bubble Sort [ASM-MIPS]

    # Program: Bubble sort # Language: MIPS Assembly (32-bit) # Arguments: 5 unordered numbers stored in ...

  9. HDU 5775 Bubble Sort(冒泡排序)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

随机推荐

  1. Winform实现右下角弹窗_提示信息

    网页是否经常在电脑右下角弹窗显示消息?其实Winform也是可以实现的.下面介绍两种方法. 第一步:设计窗体 第二步:实现代码 第一种方法 引用user32 声明常量 窗体Load事件 窗体FormC ...

  2. 利用反射和ResultSetMetaData实现DBUtils的基本功能

    DBUtils大大简化了JDBC的书写,极大的提高了开发效率,和数据库连接池一起,简化了JDBC开发的流程.简易的自定义数据库连接池可以通过装饰者设计模式和动态代理模式得到很简单的实现,那么DBUti ...

  3. 【转载】协同过滤 & Spark机器学习实战

    因为协同过滤内容比较多,就新开一篇文章啦~~ 聚类和线性回归的实战,可以看:http://www.cnblogs.com/charlesblc/p/6159187.html 协同过滤实战,仍然参考:h ...

  4. __VA_ARGS__可变参数宏

    #define qWiFiDebug(format, ...) qDebug("[WiFi] "format" File:%s, Line:%d, Function:%s ...

  5. Android API 21 Toolbar Padding

    up vote117down votefavorite 44 How do I get rid of the extra padding in the new Toolbar with Android ...

  6. Ajax全解

    jQuery确实是一个挺好的轻量级的JS框架,能帮助我们快速的开发JS应用,并在一定程度上改变了我们写JavaScript代码的习惯. 我们先来看一些简单的方法,这些方法都是对jQuery.ajax( ...

  7. Javascript之链式运动框架1

    第一部分:HTML内容: <script src="6-1.js"></script> <script> window.onload=funct ...

  8. Android Genymotion无法启动

    virtualbox无法启动,闷声作大死改了uxtheme.dll导致系统无法启动,正确的解决方法 关于在64位win7下运行Virtualbox安装系统时出错(提示VBoxDD.DLL错误)的解决方 ...

  9. iOS开发Swift篇—(六)流程控制

    iOS开发Swift篇—(六)流程控制 一.swift中的流程控制 Swift支持的流程结构如下: 循环结构:for.for-in.while.do-while 选择结构:if.switch 注意:这 ...

  10. [Jquery]某宝图片轮播(无缝、带左右切换按钮)

    [效果] 左右移动(非渐隐) [思路] 1.结构与样式 ①最外层div盒子当容器,里面ul宽度无限大并且相对定位(到时候移动其实移的是ul的left) ②按钮的透明度可用background:rgba ...