結果

問題 No.2924 <===Super Spaceship String===>
ユーザー elphe
提出日時 2024-12-05 17:49:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 560 bytes
コンパイル時間 800 ms
コンパイル使用メモリ 77,452 KB
最終ジャッジ日時 2025-02-26 11:06:04
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdint>
#include <vector>
#include <stack>

using namespace std;

int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;

	int32_t i, j, removed = 0;
	stack<int32_t> s;
	for (i = j = 0; i != S.size(); ++i)
		switch (S[i])
		{
		case '<':
			s.push(j), j = 0;
			break;

		case '=':
			++j;
			break;

		case '>':
			if (!s.empty())
			{
				if (j != 0) removed += j + 2, j = s.top(), s.pop();
				else while (!s.empty()) s.pop();
			}
			break;
		}

	cout << S.size() - removed << '\n';
	return 0;
}
0