結果

問題 No.2924 <===Super Spaceship String===>
ユーザー bluemegane
提出日時 2024-10-13 16:46:49
言語 C#
(.NET 8.0.404)
結果
WA  
実行時間 -
コード長 884 bytes
コンパイル時間 12,929 ms
コンパイル使用メモリ 168,064 KB
実行使用メモリ 192,208 KB
最終ジャッジ日時 2024-10-13 16:47:10
合計ジャッジ時間 16,415 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 5 WA * 3 RE * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (89 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.Collections.Generic;
using System;

public class Hello
{
    static void Main()
    {
        var s = Console.ReadLine().Trim();
        getAns(s);
    }
    static void getAns(string s)
    {
        var st = new Stack<int>();
        var f = false;
        foreach (var x in s)
        {
            if (x == '<') { st.Push(0); f = false; }
            else if (x == '=')
            {
                var top = st.Peek();
                if (top == 0) f = true;
                else if (top == 1) continue;
                st.Push(1);
            }
            else
            {
                if (f)
                {
                    while (true)
                    {
                        if (st.Pop() == 0) break;
                    }
                }
                else st.Push(2);
            }
        }
        Console.WriteLine(st.Count);
    }
}
0