提交时间:2023-12-30 11:12:51

运行 ID: 118427

# include <bits/stdc++.h> using namespace std ; char s [114514] ; stack <char> lne ; int main ( ) { cin >> s ; int l = strlen ( s ) ; for ( int i = 0 ; i < l ; i ++ ) { if ( s [i] != '#' && s [i] != '@' ) { lne . push ( s [i] ) ; } if ( s [i] == '#' ) { lne . pop ( ) ; } if ( s [i] == '@' ) { while ( ! lne . empty ( ) ) { lne . pop ( ) ; } } } string ans = "" ; while ( ! lne . empty ( ) ) { ans = lne . top ( ) + ans ; lne . pop ( ) ; } cout << ans << endl ; return 0 ; }