Why?
查看原帖
Why?
1673827
xbb130607楼主2025/7/27 13:31

为什么我的代码用C++14 + O2优化是RE,不开O2是100分?

#include <iostream>
#include <string>
using namespace std;
inline string str() {
	char c;
	int D;
	string s="";
	string ans="";
	while(cin >> c){
		if(c == '[') {
			cin >> D;
			s = str();
			for(int i=1 ; i<=D ; ++i)
				ans += s;
		}
		else if(c == ']') {
			return ans;
		}
		else
			ans += c;
	}
}
int main() {
	cout << str();
	return 0;
}
2025/7/27 13:31
加载中...