这道题即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. 《利用python进行数据分析》读书笔记--第九章 数据聚合与分组运算(一)

    http://www.cnblogs.com/batteryhp/p/5046450.html 对数据进行分组并对各组应用一个函数,是数据分析的重要环节.数据准备好之后,通常的任务就是计算分组统计或生 ...

  2. vpsmate安装

    安装需求 操作系统:CentOS/Redhat 5.4 或 5.4 以上版本,32位或64位均可,推荐使用 CentOS 6.2 64位. 内存大小:运行时占用约 20MB 左右的服务器内存. 请使用 ...

  3. 我的sql 记录

    ----------2017-01-03 21:56:56---------- --字符串分隔 start------------- use LDSQL GO CREATE function [dbo ...

  4. JS 拼接字符串数组

    1.格式1 1.1例子 [ {name: '北京',value: Math.round(Math.random()*1000)}, {name: '天津',value: Math.round(Math ...

  5. Oracle客户端配置

    1.  打开开发生产数据库系统,点击下载Oracle_12C_Client32,并且解压缩. 2.  找到文件下的setup.exe文件,并且执行. 3.  等待数秒,在如下界面中选择第二项,管理员, ...

  6. onSaveInstanceState的执行时机

    当某个activity变得"容易"被系统销毁时,该activity的onSaveInstanceState就会被执行,除非该activity是被用户主动销毁的,例如当用户按BACK ...

  7. docker里重装mysql

    1.查看ubuntu下装了什么软件: dpkg -l 2.删除mariadb: apt-get autoremove --purge mariadb-server-10.0 apt-get remov ...

  8. GOLANG 常用命令

    golang常用命令: 命令 功能 build      编译包和依赖 run 编译并且直接运行 install 编译安装包和依赖 get 下载并安装包和依赖 fmt 调用gofmt格式化源码文件 d ...

  9. kali安装java1.7

    1.先去这里下载你需要的版本 http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html 我 ...

  10. 微信小程序-视图模板

    定义模板 使用name属性,作为模板的名字.然后在<template/>内定义代码片段,如: <!-- index: int msg: string time: string --& ...