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 ...
随机推荐
- Nginx + Tomcat7 + redis session一致性问题
Nginx 作负载均衡时,由于是每次都需要把请求分发到不同的机器,同一个用户在一台机器上创建了 session,下一次的请求很有可能会转发到另外一台机器,会造成 session 丢失.我们可以使用 R ...
- IT兄弟连 JavaWeb教程 jQuery对AJAX的支持经典面试题
1.简述对Ajax的理解 AJAX是Asynchronous JavaScript and Xml异步的JavaScript和Xml.它一种用来改善用户体验的技术其实质是使用XMLHttpReques ...
- tomcat mamcached session共享方法
下载后输入命令安装命令: c:\memcached\memcached.exe -d install 然后再输入如下命令把其作为win service常驻启动: c:\memcached\memcac ...
- centos7.3下配置本地yum仓库
部署openstack时,网络yum源安装慢,而且经常中的提示找不到mirrors,所以配置一个本地的安装源很有必要,来解决这个揪心的问题. 安装:yum install yum-utils crea ...
- 转 mysql有一个warning,但可以执行成功
mysql有一个warning,但可以执行成功,报整型值错误,怎么解,求支招 转 http://tieba.baidu.com/p/4558183228
- 022 Generate Parentheses 生成括号
给 n 对括号,写一个函数生成所有合适的括号组合.比如,给定 n = 3,一个结果为:[ "((()))", "(()())", "(())() ...
- ubuntu apache2配置多站点
ubuntu下使用sudo apt-get install apache2方法安装时,配置文件主要在/etc/apache2/目录下.主要有: apache2.conf : 主配置文件,会通过incl ...
- 牛客网练习赛26B(简单的dp)
题目链接:https://www.nowcoder.com/acm/contest/180/B 链接:https://www.nowcoder.com/acm/contest/180/B来源:牛客网 ...
- OpenStack local.conf
# Sample ``local.conf`` for user-configurable variables in ``stack.sh`` # NOTE: Copy this file to th ...
- ${openid_wx} el解析式放入url的“”里才起作用。
window.location.href="${ctx }/wx/reservation/content?shopid="+shopid+"&&openi ...