結果
問題 |
No.1894 Delete AB
|
ユーザー |
![]() |
提出日時 | 2022-04-08 22:52:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 602 bytes |
コンパイル時間 | 606 ms |
コンパイル使用メモリ | 69,764 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-28 13:47:11 |
合計ジャッジ時間 | 1,370 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 1 WA * 13 |
ソースコード
#include <iostream> #include <algorithm> #include <string> #include <vector> using namespace std; int main() { int T; cin >> T; while (T--) { int n; string s; cin >> n >> s; int i, j; string ans; for (i = 0; i < n; ) { if (s[i] == 'B') { ans += s[i]; i++; } //消せないので追加 else { int cnt = 0; for (j = i; j < n; j++) { if (s[j] == 'A') cnt++; else cnt--; if (cnt < 0) break; //消せる } if (j == n) { for (; i < n; i++) ans += s[i]; break; } else { i = j; } } } cout << ans << endl; } return 0; }