为什么这样是错的
查看原帖
为什么这样是错的
376679
初星逝者楼主2023/11/12 16:06

思路很简单,就是找 B,然后合并前面的后面的,样例全过,但是不知道为什么会 wawa 3个点

求dalao给出 hackhack

#include <bits/stdc++.h>
using namespace std;

string s;
string tmp;
int prepos=0;

int step=0;
int main(){
	cin >> s;
	while(1){
		step++;
		int pos=s.find('B',prepos);
		if(pos==s.npos)pos=0;
		if(pos-1>=0&&pos+1<s.length()&&s[pos-1]=='A'&&s[pos+1]=='C')s=s.substr(0,pos-1)+s.substr(pos+2,s.length()-1);
		if(step>=900000)break;
		prepos=pos+1;
	}
	cout<<s;
	return 0;
}
2023/11/12 16:06
加载中...