結果

問題 No.1894 Delete AB
ユーザー masayamatumasayamatu
提出日時 2022-06-25 15:03:12
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 175 ms / 2,000 ms
コード長 1,298 bytes
コンパイル時間 16,970 ms
コンパイル使用メモリ 166,908 KB
実行使用メモリ 200,472 KB
最終ジャッジ日時 2024-04-26 21:35:07
合計ジャッジ時間 10,667 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
29,952 KB
testcase_01 AC 175 ms
56,448 KB
testcase_02 AC 166 ms
52,848 KB
testcase_03 AC 135 ms
45,184 KB
testcase_04 AC 142 ms
47,488 KB
testcase_05 AC 145 ms
48,640 KB
testcase_06 AC 150 ms
49,280 KB
testcase_07 AC 149 ms
49,664 KB
testcase_08 AC 165 ms
53,376 KB
testcase_09 AC 124 ms
44,928 KB
testcase_10 AC 140 ms
49,536 KB
testcase_11 AC 141 ms
49,152 KB
testcase_12 AC 144 ms
50,432 KB
testcase_13 AC 166 ms
52,992 KB
testcase_14 AC 127 ms
200,472 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (100 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
//using static CompLib.CompLib;
//using DataStructure;

namespace atcoder
{
    class Program
    {
        const int intMax = 1000000000;
        const long longMax = 2000000000000000000;
        static void Main(string[] args)
        {
            int T = int.Parse(Console.ReadLine());
            while (T-- > 0)
            {
                int N = int.Parse(Console.ReadLine());
                String S = Console.ReadLine();
                var stack = new Stack<char>();
                for (int i = S.Length - 1; i >= 0; i--)
                {
                    stack.Push(S[i]);
                    if (stack.Count > 2)
                    {
                        if (stack.ElementAt(1) == 'B' && stack.ElementAt(0) == 'A' && stack.ElementAt(2) == 'B')
                        {
                            stack.Pop();
                            stack.Pop();
                        }
                    }
                }
                String ans = "";
                while (stack.Count > 0)
                {
                    ans += stack.Pop();
                }
                Console.WriteLine(ans);
            }
        }
    }
}
0