水题

#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std; vector<int> g[];
int n,m;
char s[+],ans[+];
int k[];
char t1[],t2[]; void init()
{
for(int i=; i<; i++) g[i].clear();
} int main()
{
while(~scanf("%d%d",&n,&m))
{
scanf("%s",s);
init();
int len=strlen(s);
for(int i=; i<len; i++)
g[s[i]-'a'].push_back(i);
for(int i=; i<; i++) k[i]=i; for(int i=; i<m; i++)
{
scanf("%s%s",t1,t2);
swap(k[t1[]-'a'],k[t2[]-'a']);
}
for(int i=; i<; i++)
for(int j=; j<g[k[i]].size(); j++)
ans[g[k[i]][j]]='a'+i;
ans[n]='\0';
printf("%s\n",ans);
}
return ;
}

CodeForces 591B Rebranding的更多相关文章

  1. codeforces 591B Rebranding (模拟)

    Rebranding Problem Description The name of one small but proud corporation consists of n lowercase E ...

  2. 字符串 || CodeForces 591B Rebranding

    给一字符串,每次操作把字符串中的两种字母交换,问最后交换完的字符串是多少 arr数组记录每个字母最后被替换成了哪个字母 读入字符前面加一空格 scanf(" %c %c", &am ...

  3. CodeForces 591B

    题目链接: http://codeforces.com/problemset/problem/591/B 题意: 给你一串字符串,字符串里的字符全是a-z的小写字母,下面的m行,是字符串的交换方式, ...

  4. Codeforces Round #327 (Div2) A~E

    CodeForces 591A 题意:在距离为L的两端A,B,相向发射魔法,a(以P1的速度)-->B,A<--b(以P2的速度).假设a-->B,途中相遇,则返回到原点A<- ...

  5. Codeforces Round #327 (Div. 2) B. Rebranding 水题

    B. Rebranding Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/problem ...

  6. 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 ...

  7. Codeforces Round #327 (Div. 2) B. Rebranding 模拟

    B. Rebranding   The name of one small but proud corporation consists of n lowercase English letters. ...

  8. Codeforces 591 B:Rebranding

    B. Rebranding time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  9. Codeforces Round #327 (Div. 2) B Rebranding(映射)

    O(1)变换映射,最后一次性替换. #include<bits/stdc++.h> using namespace std; typedef long long ll; ; char s[ ...

随机推荐

  1. Chapter 1 First Sight——34

    "Was that the boy I sat next to in Biology?" I asked artlessly. 你是生物课坐在我旁边的男生吗?我天真烂漫的问道. & ...

  2. 导入Excel后绑定GridView实例

    http://blog.csdn.net/loveheronly/article/details/6715552 项目中经常用到导入导出的例子,前面做了导出的例子,现在把导入Excel的数据的例子也把 ...

  3. hdu_1558_Segment set(并查集+计算几何)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1558 题意:P为画线段,Q为询问当前这条线段所在的集合有多少线段 题解:如果两条线段有交点,那么就连接 ...

  4. 禁止 一些地区的ip用户访问 网站

    01 framework.php 中 获取请求的ip地址.保存为常量 define('IP', request::get_clientip()); 02 setting表中.属于system模块,保存 ...

  5. Mac 下格式化U盘

    diskutil list 查看U盘盘符: lapommedeMacBook-Pro:~ lapomme$ diskutil list /dev/disk0 (internal, physical): ...

  6. AngularJS 的表单验证

    最近开始学习angularjs,学到表单验证的时候发现有必要学习下大神的好文章: 转:http://www.oschina.net/translate/angularjs-form-validatio ...

  7. Oracle record 解锁

    Oracle修改表中记录时出现record is locked by another user的弹出框问题 是因为在操作表中数据时没有commit,导致表被锁. 执行下面两行语句: (1)查看被锁表的 ...

  8. 【转】4G手机打电话为什么会断网 4G上网和通话不能并存原因分析

    与2G/3G相比,4G最大的特色就是提供了超过100Mbps的峰值速率,既然速度都可以秒掉20M的光纤固网了,那用来语音通话不就更是小菜一碟了吗?很遗憾,问题就出现在了这里. 由于目前的LTE网络(4 ...

  9. css(非表格变成表格用)

    父元素:display:table: 子元素:display:table-cell:vertical-align:middle:

  10. jQuery 图片随滚动条滚动加载

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...