hack:
```
AB
BA
```
by Rosaya @ 2023-05-22 19:39:32
@[凤凰工作室](/user/491007) 我是60分
```cpp
#include <iostream>
#include <cstring>
using namespace std;
int n;
char a[9], b[9], map[9];
inline void dfs(int l, int r, int x, int y) {
if (l > r) return ;
putchar(b[y]);
int root = map[b[y] - 'A' + 1];
dfs(l, root - 1, x, x + root - l - 1);
dfs(root + 1, r, x + root - 1, y - 1);
}
int main() {
scanf("%s%s", a + 1, b + 1);
n = strlen(a + 1);
for (int i = 1; i <= n; i ++ ) map[a[i] - 'A' + 1] = i;
dfs(1, n, 1, n);
putchar('\n');
return 0;
}
```
你是否考虑一下递推?或者dp,这应该不会MLE了
by ttltony @ 2023-05-29 13:17:27