結果
問題 | No.1894 Delete AB |
ユーザー | ruthen |
提出日時 | 2022-04-08 22:49:47 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 1,190 bytes |
コンパイル時間 | 1,761 ms |
コンパイル使用メモリ | 167,512 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-08-19 01:19:35 |
合計ジャッジ時間 | 2,082 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge9 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 3 ms
4,376 KB |
testcase_02 | AC | 3 ms
4,380 KB |
testcase_03 | AC | 6 ms
4,380 KB |
testcase_04 | AC | 6 ms
4,376 KB |
testcase_05 | AC | 6 ms
4,376 KB |
testcase_06 | AC | 5 ms
4,380 KB |
testcase_07 | AC | 5 ms
4,376 KB |
testcase_08 | AC | 7 ms
4,380 KB |
testcase_09 | AC | 3 ms
4,376 KB |
testcase_10 | AC | 3 ms
4,380 KB |
testcase_11 | AC | 2 ms
4,376 KB |
testcase_12 | AC | 3 ms
4,380 KB |
testcase_13 | AC | 2 ms
4,380 KB |
testcase_14 | AC | 3 ms
4,376 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef _RUTHEN #include "debug.hpp" #else #define show(...) true #endif using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) template <class T> using V = vector<T>; int main() { ios::sync_with_stdio(false); cin.tie(0); int T; cin >> T; while (T--) { int N; cin >> N; string S; cin >> S; V<char> stk; for (int i = N - 1; i >= 0; i--) { stk.push_back(S[i]); int len = stk.size(); if (len >= 2 && stk[len - 1] == 'A' && stk[len - 2] == 'B') { if (len == 2) { continue; } else if (stk[len - 3] == 'B') { stk.pop_back(); stk.pop_back(); } else if (len == 3) { continue; } else if (stk[len - 4] == 'A') { continue; } else { continue; } } } string ans; for (auto &c : stk) ans += c; reverse(ans.begin(), ans.end()); cout << ans << '\n'; } return 0; }