水题

#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. INI文件的写入与读取

    INI文件的写入与读取 [节名]         '[]中的节名对应此API的第一参数 Name=内容      'Nmae对应此API的第二参数 API的第三参数是没有取到匹配内容时返回的字符串; ...

  2. nefu 72 N!

    Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N! Input One N in one line, ...

  3. ECOS-认证地址

    ECOS系统授权认证,需要和Shopex认证中心互联.当服务器DNS无效时.需要绑定host强行解析服务器强行解析以下vim /etc/hosts 122.144.135.142 service.sh ...

  4. 昨天上架出现问题,you binary is not optimized for iphone5.。。。。

    这个时候只需要加一个lanuch image 就可以了

  5. Winsock SPI-Socks5-SSL

  6. go mode

    https://github.com/dominikh/go-mode.el http://blog.altoros.com/golang-part-1-main-concepts-and-proje ...

  7. sql中 replace函数

    例用 xxx 替换 abcdefghi 中的字符串 cde. SELECT REPLACE(''abcdefghicde'',''cde'',''xxx'')

  8. 改良UIScrollView滚动视图

    #define HEIGHT  self.view.frame.size.height #define WIDTH    self.view.frame.size.width @interface V ...

  9. sql查询百分号的方法

    select * from [tablename] where [col] like '%100/%%' escape '/'

  10. Stammering Aliens

    Stammering Aliens Time Limit: 2000MS   Memory Limit: 65536K       Description Dr. Ellie Arroway has ...