这道题即THUSC 2015 t3...只不过数据范围$n, m ≤ 10^5$

可以上网查这个鬼畜的东西"Burrows-Wheeler Transform"

这道题要用到解压缩也就是IBWT算法,复杂度$O(n + m)$

 /**************************************************************
Problem: 2408
User: rausen
Language: C++
Result: Accepted
Time:24 ms
Memory:884 kb
****************************************************************/ #include <cstdio> using namespace std;
const int N = 1e4 + ; int getint(); int n, m, st;
int a[N], next[N], cnt[]; int main() {
int i, j;
n = getint(), m = getint();
for (i = ; i <= n; ++i) ++cnt[(a[i] = getint()) + ];
for (i = ; i <= m; ++i) cnt[i] += cnt[i - ];
for (i = ; i <= n; ++i) next[++cnt[a[i]]] = i;
for (i = st = ; i <= n; ++i) if (a[i] < a[st]) st = i;
for (i = , j = st; i <= n; ++i) printf("%d%c", a[j], i == n ? '\n' : ' '), j = next[j];
return ;
} const int BUF_SIZE = ;
char buf[BUF_SIZE], *buf_s = buf, *buf_t = buf + ;
#define isdigit(x) ('0' <= x && x <= '9')
#define PTR_NEXT() { \
if (++buf_s == buf_t) \
buf_s = buf, buf_t = buf + fread(buf, , BUF_SIZE, stdin); \
} inline int getint() {
register int x = ;
while (!isdigit(*buf_s)) PTR_NEXT();
while (isdigit(*buf_s)) {
x = x * + *buf_s - '';
PTR_NEXT();
}
return x;
}

(p.s. 窝考试的时候sb。。。只想出来了$O(mn)$的算法QAQAQQQ)

BZOJ2408 混乱的置换的更多相关文章

  1. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  2. 【做题】agc016d - XOR Replace——序列置换&环

    原文链接 https://www.cnblogs.com/cly-none/p/9813163.html 题意:给出初始序列\(a\)和目标序列\(b\),都有\(n\)个元素.每次操作可以把\(a\ ...

  3. [LeetCode] LFU Cache 最近最不常用页面置换缓存器

    Design and implement a data structure for Least Frequently Used (LFU) cache. It should support the f ...

  4. [LeetCode] Longest Repeating Character Replacement 最长重复字符置换

    Given a string that consists of only uppercase English letters, you can replace any letter in the st ...

  5. 页置换算法FIFO、LRU、OPT

    页置换算法FIFO.LRU.OPT 为什么需要页置换 在地址映射过程中,若在页面中发现所要访问的页面不再内存中,则产生缺页中断.当发生缺页中断时操作系统必须在内存选择一个页面将其移出内存,以便为即将调 ...

  6. 【bzoj1231】[Usaco2008 Nov]mixup2 混乱的奶牛

    题目描述 混乱的奶牛[Don Piele, 2007]Farmer John的N(4 <= N <= 16)头奶牛中的每一头都有一个唯一的编号S_i (1 <= S_i <= ...

  7. NOIP提高模拟题 混乱的队伍

    混乱的奶牛 Description 混乱的奶牛 [Don Piele, 2007] Farmer John的N(4 <= N <= 16)头奶牛中的每一头都有一个唯一的编号S_i (1 & ...

  8. POJ2369 Permutations(置换的周期)

    链接:http://poj.org/problem?id=2369 Permutations Time Limit: 1000MS   Memory Limit: 65536K Total Submi ...

  9. POJ1026 Cipher(置换的幂运算)

    链接:http://poj.org/problem?id=1026 Cipher Time Limit: 1000MS   Memory Limit: 10000K Total Submissions ...

随机推荐

  1. linux问题

    make:进入目录'/opt/FriendlyARM/tiny4412/05android/android-4.1.2'target Dex: framework trouble writing ou ...

  2. maven+spark2.0.0最大连通分量

    运用到了spark2.0.0的grarhx包,要手动的在pom.xml里面添加依赖包,要什么就在里面添加依赖,然后在run->maven install

  3. nodejs httpserver

    用nodejs服务器去拿取后台的数据.(我刚开始学的nodejs的时候是一个蒙圈的宝宝 t.t,开始接触的时候,在本地搭建去拿数据.之前菜鸟的我都不知道路由是神马[囧囧]). --> index ...

  4. jdk 设计模式

    摘自:http://blog.csdn.net/bakeloar/article/details/6608806

  5. python之路2(基础详解)

    python一切都是对象: 列子:

  6. Cheatsheet: 2016 03.01 ~ 03.31

    JAVA Quick Java 8 or Java 7 Dev Environments With Docker Printing arrays by hacking the JVM Mobile H ...

  7. $.ajax()方法所有参数详解;$.get(),$.post(),$.getJSON(),$.ajax()详解

    [一]$.ajax()所有参数详解 url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址. type: 要求为String类型的参数,请求方式(post或get)默认为get.注 ...

  8. kali Linux添加add-apt-repository

    Debian让用户可以通过一个名为add-apt-repository的应用程序,添加和使用PPA软件库,不过Kali Linux在其默认的程序包列表中并不含有该应用程序.就Kali而言,由于这是个特 ...

  9. MySQL 5.7 解压版安装配置

    测试环境 系统:Windows 10专业版 版本:MySQL Server 5.7.14   提纲 修改配置文件 初始化 安装服务.启动服务 修改root密码   步骤 1.解压安装包 在MySQL官 ...

  10. position absolute 绝对定位 设置问题

     今天在做布局的时候,用到了绝对定位, 父级元素相对定位,子元素两个,一个元素正常文档流布局并且在前面,另一个元素绝对定位排在后面,但设置了好久,绝对定位的子元素都不会覆盖其上面的兄弟元素,最后,不知 ...