Codeforces Round #327 (Div. 2) B Rebranding(映射)
O(1)变换映射,最后一次性替换。
#include<bits/stdc++.h>
using namespace std; typedef long long ll; const int LEN = 2e5+;
char s[LEN];
char mp[];
int pos[];
//#define LOCAL
int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
#endif
for(int i = ; i < ; i++) pos[i] = i;
int n, m; scanf("%d%d%s",&n,&m,s);
while(m--){
char x[], y[]; scanf("%s %s", x, y);
swap(pos[*x-'a'], pos[*y-'a']);
}
for(int i = ; i < ; i++) mp[pos[i]] = i+'a';
for(int i = ; i < n; i++) putchar(mp[s[i]-'a']);
return ;
}
Codeforces Round #327 (Div. 2) B Rebranding(映射)的更多相关文章
- Codeforces Round #327 (Div. 2) B. Rebranding C. Median Smoothing
B. Rebranding The name of one small but proud corporation consists of n lowercase English letters. T ...
- Codeforces Round #327 (Div. 2) B. Rebranding 水题
B. Rebranding Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/problem ...
- Codeforces Round #327 (Div. 2) B. Rebranding 模拟
B. Rebranding The name of one small but proud corporation consists of n lowercase English letters. ...
- Codeforces Round #327 (Div. 2) A. Wizards' Duel 水题
A. Wizards' Duel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/prob ...
- Codeforces Round #327 (Div. 2)B(逻辑)
B. Rebranding time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- Codeforces Round #327 (Div. 2)
题目传送门 水 A - Wizards' Duel 题目都没看清就写了,1e-4精度WA了一次... /************************************************ ...
- Codeforces Round #327 (Div. 2) E. Three States BFS
E. Three States Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/probl ...
- Codeforces Round #327 (Div. 2) D. Chip 'n Dale Rescue Rangers 二分 物理
D. Chip 'n Dale Rescue Rangers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/co ...
- Codeforces Round #327 (Div. 2) C. Median Smoothing 找规律
C. Median Smoothing Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/p ...
随机推荐
- (PHP)redis Zset(有序集合 sorted set)操作
/** * * Zset操作 * sorted set操作 * 有序集合 * sorted set 它在set的基础上增加了一个顺序属性,这一属性在修改添加元素的时候可以指定,每次指定后,zset会自 ...
- 初识XML
前言 前期敲机房的时候,总是写配置文件,后来到ASP.NET学习中也遇到了XML,可是什么是XML呢,它又是用来干什么的呢?请听我细细道来. 内容 定义 (eXtensible Markup Lang ...
- Listener、Filter、Servlet的创建及初始化顺序
一.创建顺序 1.web.xml文件中的加载顺序为:listener-filter-servlet 2.如果web.xml中配置了<context-param>,初始化顺序: contex ...
- Gson本地和服务器环境不同遇到的Date转换问题 Failed to parse date []: Invalid time zone indicator
GoogleGson在处理Date格式时有个小陷阱,在不同环境中部署时可能会遇到问题. Gson默认处理Date对象的序列化/反序列化是通过一个SimpleDateFormat对象来实现的,通过下面的 ...
- iOS端实现节日换肤
本文是我在网上看到一篇不错的文章,因为之前没接触过,所以特意转过来,和大家一起分享下..以下正文: 一.问题的提出 不知道大家有没有发现, 元旦期间, 很多APP界面里的图标都换成了具有节日气氛的样式 ...
- 洛谷 P3128 [USACO15DEC]最大流Max Flow
题目描述 \(FJ\)给他的牛棚的\(N(2≤N≤50,000)\)个隔间之间安装了\(N-1\)根管道,隔间编号从\(1\)到\(N\).所有隔间都被管道连通了. \(FJ\)有\(K(1≤K≤10 ...
- Java基础笔记(十一)—— 字符串与数组
字符串的声明与初始化主要两种:String s1=new String("abc"); 或 String s2="abc"; String ...
- return this链式操作
function Fn(){}; Fn.prototype = { constructor:Fn, a:function(){ alert(1); return this; //实现链式操作.即fn. ...
- .gitkeep--git提交空目录的解决方法
前言 git和 svn不同,仅仅跟踪文件的变动,不跟踪目录.所以,一个空目录,如果里面没有文件,即便 git add 这个目录,另外在别处 check out 的时候,是没有这个空目录的. 只跟踪文件 ...
- POJ 2068 NIm (dp博弈,每个人都有特定的取最大值)
题目大意: 有2n个人,从0开始编号,按编号奇偶分为两队,循环轮流取一堆有m个石子的石堆,偶数队先手,每个人至少取1个,至多取w[i]个,取走最后一个石子的队伍输.问偶数队是否能赢. 分析: 题目数据 ...