結果
| 問題 |
No.1894 Delete AB
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-06-25 15:01:24 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,531 bytes |
| コンパイル時間 | 11,018 ms |
| コンパイル使用メモリ | 167,832 KB |
| 実行使用メモリ | 209,560 KB |
| 最終ジャッジ日時 | 2024-11-14 12:57:37 |
| 合計ジャッジ時間 | 13,452 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 2 WA * 12 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (98 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/
ソースコード
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();
}
}
else if (stack.Count == 2 && stack.ElementAt(1) == 'B' && stack.ElementAt(0) == 'A' && i >= 2)
{
stack.Pop();
stack.Pop();
}
}
String ans = "";
while (stack.Count > 0)
{
ans += stack.Pop();
}
Console.WriteLine(ans);
}
}
}
}