結果

問題 No.1894 Delete AB
ユーザー laneguelanegue
提出日時 2022-04-08 22:00:58
言語 D
(dmd 2.106.1)
結果
TLE  
実行時間 -
コード長 469 bytes
コンパイル時間 2,235 ms
コンパイル使用メモリ 157,380 KB
実行使用メモリ 7,904 KB
最終ジャッジ日時 2023-09-04 16:40:33
合計ジャッジ時間 6,137 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 179 ms
7,868 KB
testcase_02 AC 208 ms
7,904 KB
testcase_03 AC 22 ms
4,380 KB
testcase_04 AC 25 ms
4,380 KB
testcase_05 AC 25 ms
4,380 KB
testcase_06 AC 27 ms
4,380 KB
testcase_07 AC 27 ms
4,376 KB
testcase_08 AC 35 ms
4,376 KB
testcase_09 AC 39 ms
4,376 KB
testcase_10 AC 54 ms
4,376 KB
testcase_11 AC 85 ms
4,376 KB
testcase_12 AC 117 ms
4,820 KB
testcase_13 TLE -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main(){
	auto T = readln.chomp.to!int;
	for(auto t = 0; t < T; t++){
		auto N = readln.chomp.to!int;
		auto S = readln.chomp;
		auto s = "";
		while(1){
			s = "";
			for(auto i = 0; i < S.length; i++){
				if(S[i] == 'A' && i < S.length - 2 && S[i + 1] == 'B' && S[i + 2] == 'B'){
					i += 2;
				}
				s ~= S[i];
				//stderr.writefln("%d %s", i, s);
			}
			if(S.length == s.length) break;
			S = s;
			//stderr.writeln(s);
		}
		writeln(s);
	}
}
0