結果
問題 | No.1894 Delete AB |
ユーザー | kokatsu |
提出日時 | 2022-04-08 22:09:30 |
言語 | D (dmd 2.107.1) |
結果 |
AC
|
実行時間 | 20 ms / 2,000 ms |
コード長 | 755 bytes |
コンパイル時間 | 3,500 ms |
コンパイル使用メモリ | 200,876 KB |
実行使用メモリ | 4,388 KB |
最終ジャッジ日時 | 2023-09-04 16:41:21 |
合計ジャッジ時間 | 4,198 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,384 KB |
testcase_01 | AC | 3 ms
4,384 KB |
testcase_02 | AC | 3 ms
4,380 KB |
testcase_03 | AC | 16 ms
4,384 KB |
testcase_04 | AC | 17 ms
4,384 KB |
testcase_05 | AC | 18 ms
4,380 KB |
testcase_06 | AC | 18 ms
4,388 KB |
testcase_07 | AC | 17 ms
4,384 KB |
testcase_08 | AC | 20 ms
4,380 KB |
testcase_09 | AC | 6 ms
4,384 KB |
testcase_10 | AC | 6 ms
4,380 KB |
testcase_11 | AC | 4 ms
4,384 KB |
testcase_12 | AC | 4 ms
4,380 KB |
testcase_13 | AC | 3 ms
4,380 KB |
testcase_14 | AC | 2 ms
4,380 KB |
ソースコード
import std; void main() { int T; readf("%d\n", T); foreach (_; 0 .. T) { int N; readf("%d\n", N); auto S = readln.chomp; dchar[] res; int cntB; foreach_reverse (s; S) { if (s == 'A') { if (cntB > 1) { --cntB; } else { while (cntB > 0) { res ~= 'B'; --cntB; } res ~= 'A'; } } else { ++cntB; } } while (cntB > 0) { res ~= 'B'; --cntB; } res.reverse; res.writeln; } }