全挖
  • 板块灌水区
  • 楼主linhaoranfather
  • 当前回复18
  • 已保存回复18
  • 发布时间2024/8/21 10:19
  • 上次更新2024/8/21 12:46:03
查看原帖
全挖
1175827
linhaoranfather楼主2024/8/21 10:19

题目

代码:

#include <bits/stdc++.h>
#define int long long
#define f(i,a,b,c) for(int i=a;i<=b;i+=c)
#define ff(i,a,b,c) for(int i=a;i>b;i-=c)
using namespace std;

const int N=1e5+1;
int n,cnt;
char c[N];
string s;
vector<char> st;
int read(){int X=0,F=1;char C=getchar();while(C<'0'||C>'9'){if(C=='-') F=-1;C=getchar();}while(C>='0'&&C<='9'){X=X*10+C-'0';C=getchar();}return X*F;}
signed main(){
	n = read();
	while (n--) {
		getline(cin,s);
		f(i,0,s.size()-1,1) {
			char x = s[i];
			if (x == '#') {
				if (!st.empty()) st.pop_back();
			}
			else if (x == '@') {
				while (!st.empty()) st.pop_back();
			}
			else st.push_back(x);
		}
		f(i,0,st.size(),1) cout << st[i];
		cout << endl;
	}
	
	return 0;
}
2024/8/21 10:19
加载中...