水题

  1. #include<cstdio>
  2. #include<cstring>
  3. #include<cmath>
  4. #include<vector>
  5. #include<algorithm>
  6. using namespace std;
  7.  
  8. vector<int> g[];
  9. int n,m;
  10. char s[+],ans[+];
  11. int k[];
  12. char t1[],t2[];
  13.  
  14. void init()
  15. {
  16. for(int i=; i<; i++) g[i].clear();
  17. }
  18.  
  19. int main()
  20. {
  21. while(~scanf("%d%d",&n,&m))
  22. {
  23. scanf("%s",s);
  24. init();
  25. int len=strlen(s);
  26. for(int i=; i<len; i++)
  27. g[s[i]-'a'].push_back(i);
  28. for(int i=; i<; i++) k[i]=i;
  29.  
  30. for(int i=; i<m; i++)
  31. {
  32. scanf("%s%s",t1,t2);
  33. swap(k[t1[]-'a'],k[t2[]-'a']);
  34. }
  35. for(int i=; i<; i++)
  36. for(int j=; j<g[k[i]].size(); j++)
  37. ans[g[k[i]][j]]='a'+i;
  38. ans[n]='\0';
  39. printf("%s\n",ans);
  40. }
  41. return ;
  42. }

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

    ebtables是以太网桥防火墙,以太网工作在数据链路层,ebtables过滤数据链路层包.2.6内核内置了ebtables,要使用它必须先按装她的用户空间工具(ebtables-V2.0.6),安装 ...

  2. Nginx配置性能优化与压力测试webbench【转】

    这一篇我们来说Nginx配置性能优化与压力测试webbench. 基本的 (优化过的)配置 我们将修改的唯一文件是nginx.conf,其中包含Nginx不同模块的所有设置.你应该能够在服务器的/et ...

  3. Inno Setup入门(七)——提供安装语言选项

    Inno Setup安装目录下有一个Languages的文件夹,该文件夹提供了可供使用的语言,通过在脚本中加入[languages]段,可以实现该项功能,实现代码如下: [setup] ;全局设置,本 ...

  4. Oracle自增长序列

    create table user_info ( id number(6) primary key, username varchar2(30) not null, password varchar2 ...

  5. Mybatis 一对一,一对多,多对一,多对多的理解

    First (一对一) 首先我来说下一对一的理解,就是一个班主任只属于一个班级,一个班级也只能有一个班主任.好吧这就是对于一对一的理解 怎么来实现呢? 这里我介绍了两种方式: 一种是:使用嵌套结果映射 ...

  6. 建立TCP连接的三次握手

    请求端(通常称为客户)发送一个 SYN 报文段( SYN 为 1 )指明客户打算连接的服务器的端口,以及初始顺序号( ISN ).服务器发回包含服务器的初始顺序号( ISN )的 SYN 报文段( S ...

  7. JS IIFE写法

    IIFE 博客分类: 前端开发   介绍IIFE IIFE的性能 使用IIFE的好处 IIFE最佳实践 jQuery优化 在Bootstrap源码(具体请看<Bootstrap源码解析>) ...

  8. 简单hash[或者是哈希思想]

    题目链接 /* 有一个长度为n的只包含小写字母的字符串s,有m次操作,每次输入2个字符 A , B表示将s中的全部字符A变成B,B变成A. char sky[30],顺序记录每个字母的映射,在sky[ ...

  9. Swift 响应式编程 浅析

    这里我讲一下响应式编程(Reactive Programming)是如何将异步编程推到一个全新高度的. 异步编程真的很难 大多数有关响应式编程的演讲和文章都是在展示Reactive框架如何好如何惊人, ...

  10. 批处理数据--db2备份数据

    如果要插入数据,前提先根据主键删除记录,然后在插入. 批处理包含两个必要文件 init.bat和start.bat 文档内容如下 init.bat内容如下 @echo ondb2 connect to ...