MLE最后两个点求助
查看原帖
MLE最后两个点求助
709380
ttltony楼主2023/5/1 23:00

这看起来一点问题都没有,我还用了inline!

#include <iostream>
#include <cstring>

using namespace std;

inline int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = (x << 1) + (x << 3) + (ch ^ 48);
        ch = getchar();
    }
    return x * f;
}

inline void write(int x) {
    if (x < 0) putchar('-'), x = -x;
    if (x > 9) write(x / 10);
    putchar(x % 10 + '0');
}

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;
}
2023/5/1 23:00
加载中...