結果

問題 No.457 (^^*)
ユーザー hotpepsi
提出日時 2016-12-08 01:16:59
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 681 bytes
コンパイル時間 454 ms
コンパイル使用メモリ 59,476 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-28 04:11:32
合計ジャッジ時間 1,072 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>

using namespace std;

int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	int cnt[2] = {};
	for (int i = 0; i < 2; ++i) {
		int br[4] = {};
		for (char c : s) {
			switch (c) {
			case '(':
				if (i) {
					cnt[i] += br[3];
				} else {
					++br[0];
				}
				break;
			case '^':
				br[2] += br[1];
				br[1] = br[0];
				br[0] = 0;
				break;
			case '*':
				br[3] += br[2];
				br[2] = 0;
				break;
			case ')':
				if (i) {
					++br[0];
				} else {
					cnt[i] += br[3];
				}
				break;
			}
		}
		reverse(s.begin(), s.end());
	}
	cout << cnt[0] << " " << cnt[1] << endl;
	return 0;
}
0