結果
問題 |
No.1894 Delete AB
|
ユーザー |
![]() |
提出日時 | 2022-04-08 21:58:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 26 ms / 2,000 ms |
コード長 | 693 bytes |
コンパイル時間 | 3,750 ms |
コンパイル使用メモリ | 229,232 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-28 12:40:02 |
合計ジャッジ時間 | 4,645 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 14 |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; using ll=long long; using Graph=vector<vector<int>>; #define INF 1000000000 #define MOD 998244353 #define MAX 1000 void solve(){ int N; string S; cin>>N>>S; string T=""; for(int i=S.size()-1;i>=0;i--){ if(T.size()>0&&T[T.size()-1]=='B'&&S.size()>=2&&S[S.size()-2]=='A'&&S[S.size()-1]=='B'){ S.pop_back(); S.pop_back(); S.push_back(T[T.size()-1]); T.pop_back(); }else{ T.push_back(S[S.size()-1]); S.pop_back(); } } reverse(T.begin(),T.end()); cout<<T<<'\n'; } int main(){ int T; cin>>T; for(int i=0;i<T;i++){ solve(); } }