```明月AC惊鹊,RE半夜鸣蝉,TLE里说丰年,听取WA声一片
查看原帖
```明月AC惊鹊,RE半夜鸣蝉,TLE里说丰年,听取WA声一片
1179676
WayneLiu楼主2025/7/24 20:43

明月AC惊鹊,RE半夜鸣蝉,TLE里说丰年,听取WA声一片

#include <bits/stdc++.h>
using namespace std;
string c;
void decode(string s) {
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == ']') continue;
		else if (s[i] != '[') cout << s[i];
		else {
			int num = 0;
			string res = "";
			while (s[i + 1] != ']') {
				i++;
				if (s[i] >= '0' && s[i] <= '9') num = num * 10 + (s[i] - '0');
				else res += s[i];
			}
			for (int j = 1; j <= num; j++) decode(res);
		}
	}
}
int main() {
	cin >> c;
	decode(c);
	return 0;
}

2025/7/24 20:43
加载中...