第九个点MLE了,可以优化程序吗?
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
string expand() {
string s = "", X;
char ch;int D;
while ((ch = getchar())!='\n') {
if (ch == '[') {
cin >> D;
X = expand();
while (D--) s += X;
}
else if (ch == ']') {
return s;
}
else s += ch;
//cout << s << endl;
}
return s;
}
int main() {
cout << expand();
return 0;
}