使用STL离散化
- 把原来的数组a复制一份拷贝b
 - 用sort先把数组a排序
 - 用unique消除a里面重复的元素
 - 对于b中的每一个元素,用lower_bound找到它在a中的位置,也就是离散化之后的编号。
 - 没了。
 
 #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(void)
 {
     ] = {, , , , , }, b[];
     ; i < ; ++i) b[i] = a[i];
     sort(a, a+);
     ) - a;
     ;i < ; ++i)
         b[i] = lower_bound(a, a+len, b[i]) - a + ;
     ; i < ; ++i)
         printf("%d ", b[i]);
     printf("\n");
     ;
 }
嗨!中村。
使用STL离散化的更多相关文章
- UVa 221 (STL 离散化) Urban Elevations
		
题意: 作图为n个建筑物的俯视图,右图为从南向北看的正视图,按从左往右的顺序输出可见建筑物的标号. 分析: 题中已经说了,要么x相同,要么x相差足够大,不会出现精度问题. 给这n个建筑物从左往右排序, ...
 - CodeVS 线段覆盖1~5
		
#include <bits/stdc++.h> using namespace std; ; struct Info{int l,r;}P[Maxn]; int n,Cnt,F[Maxn ...
 - poj 2528
		
Mayor's posters Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 56958 Accepted: 16464 ...
 - 洛谷 [P1995] 程序自动分析
		
并查集+ 离散化 首先本题的数据范围很大,需要离散化, STL离散化代码: //dat是原数据,id是编号,sub是数据的副本 sort(sub + 1, sub + tot + 1); size = ...
 - Codeforces 游记
		
早就对这个比赛平台有所耳闻(事实上,之前打过一场div2惨的一批……)今天去打了一场div3. 首先还是吐槽一下这个毛子时区的比赛时间,从十点三十五到零点三十五……这种时间要不是在家根本没法打嘛…… ...
 - POJ 1170 Shopping Offers非状态压缩做法
		
Shopping Offers Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 5659 Accepted: 2361 Descr ...
 - 数据离散化 ( 以及 stl 中的 unique( ) 的用法 )+ bzoj3289:Mato的文件管理
		
http://blog.csdn.net/gokou_ruri/article/details/7723378 ↑惯例Mark大神的博客 bzoj3289:Mato的文件管理 线段树求逆序对+莫队 ...
 - 离散化——化不可能为可能(STL)
		
所谓离散,就是化连续为不连续,使得我们某种枚举的方法得以实现. 当然,离散还能够帮助我们将某些数据范围很大达到2^16,但是这些数据并不多(例如才1000+),我们可以把数据进行离散,保持他们之间的相 ...
 - [HDOJ4022]Bombing(离散化+stl)
		
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4022 一个图上有n个点,之后m个操作,每次操作一行或者一列.使得这一行或者这一列的点全部消除.每次操作 ...
 
随机推荐
- Java 集合 - LinkedList
			
一.源码解析 (1). 属性 // 链表长度 transient int size = 0; // 链首和链尾 transient Node<E> first; transient Nod ...
 - 【WEB】HTTP协议
			
http1.0和http1.1 区别,http1.1可以发送多个http请求
 - 探究chrome下的开发工具的各功能
			
F12 一.网页寻找js事件的位置,或者某一个次究竟在哪个相关的文件中可以全局搜索: ①控制台右上角的:(Customize and control DevTools)三个点点开,---->Se ...
 - 【转载】CSS规范
			
原文地址:http://www.cnblogs.com/whitewolf/p/4491707.html 目录 HTML 语法 HTML5 doctype 语言属性(Language attribut ...
 - (function($){}) 和$(function(){}) 和$(function($){}) 区别
			
请问下(function($){}) 和$(function(){}) 和$(function($){}) 有什么区别 谢谢 一.先看 jQuery(function(){ }); 全写为 jQuer ...
 - MySQL默认数据库
			
欢迎和大家交流技术相关问题: 邮箱: jiangxinnju@163.com 博客园地址: http://www.cnblogs.com/jiangxinnju GitHub地址: https://g ...
 - c#简易反射调用泛型方法
			
// 所谓程序集的简单理解,存在不同项目中(不是解决方案),即using前需要引用**.dll 1.调用当前类文件下的方法public List<T> GetByCondition< ...
 - Caché数据库学习笔记(1)
			
目录: Caché的概念和基础知识 Caché数据库的安装 创建命名空间(namespace)和数据库(database) Documentation的使用 ===================== ...
 - 电脑的f5刷新不了
			
新买的电脑,f5刷新不了页面,网上查了后发现是fn功能键的原因.同时fn+f5即可刷新.可是依然感觉好别扭... 按下fn+esc,再只按f5,就可以刷新页面了.神奇...
 - 查看Msi文件内容
			
1通过msiexec命令解压msi包 msiexec.exe /a c:\msi\installer.msi /qb targetdir=d:\msi\installer 2 使用Orca查看. Or ...