---
# System prepended metadata

title: 13572 - String Operations 1
tags: [string]

---

# 13572 - String Operations 1

>author: Utin
###### tags: `string`

---

## Brief
需建表以免TLE
String Operation目前已知共有4種變化
13572 String Operations 1
13573 String Operations 2
13692 Aftermath's Ideology
13805 Professor Bear's Challenge

## Solution 0

```c=
#include <stdio.h>
#include <string.h>

char arr[1000001], op[100001][2], table[26];
int Q, N; // Q for time, N for length

int main() {
    for (int i = 0; i < 26; i++) {
        table[i] = 'a' + i;
    }
    scanf("%s", arr);
    N = strlen(arr);
    scanf("%d", &Q);
    for (int q = 0; q < Q; q++) {
        scanf("\r%c %c", &op[q][0], &op[q][1]);
    }

    // backward
    for (int q = Q-1; q >= 0; q--) {
        table[op[q][0]-'a'] = table[op[q][1]-'a'];
    }

    // output
    for (int i = 0; i < N; i++) {
        printf("%c", table[arr[i]-'a']);
    }
    printf("\n");
}
// By Utin
```

## Reference