結果
問題 | No.1894 Delete AB |
ユーザー |
|
提出日時 | 2022-04-08 22:57:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 27 ms / 2,000 ms |
コード長 | 1,488 bytes |
コンパイル時間 | 3,963 ms |
コンパイル使用メモリ | 232,632 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-28 13:55:53 |
合計ジャッジ時間 | 4,786 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 14 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> #define rep(i,a,b) for(int i=a;i<b;i++) #define rrep(i,b) for(int i=b-1;i>=0;i--) #define rbit(i,a) for(int i=0;i<(1<<a);i++) #define all(x) (x).begin(),(x).end() #define pb(x) push_back(x); template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } typedef long long ll; typedef long double lld; using namespace std; using namespace atcoder; using mint=static_modint<1000000007>; const ll mod=998244353; //const ll mod=1e9+7; int dx[4]={1,0,-1,0}; int dy[4]={0,1,0,-1}; const string zton="0123456789"; const string atoz="abcdefghijklmnopqrstuvwxyz"; const ll inf=(1ll<<60); ll gcd(ll a,ll b){ ll r; r=a%b; if(r==0){ return b; } else{ return gcd(b,r); } } typedef pair<ll,int> P; void solve(){ int N;cin >> N; string S;cin >> S; deque<char> que; rrep(i,N){ if(S.at(i)=='B')que.push_front('B'); else if(S.at(i)=='A'){ if(que.size()<2){ que.push_front('A'); } else{ if(que.at(0)=='B'&&que.at(1)=='B'){ que.pop_front(); } else{ que.push_front('A'); } } } } for(char c:que)cout << c ; cout << endl; } int main(void){ int t;cin >> t; rep(_,0,t)solve(); }