QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#822254#9052. Balanced Tree PathWeaRD276AC ✓1004ms4240kbC++202.0kb2024-12-20 04:43:012024-12-20 04:43:02

Judging History

你现在查看的是最新测评结果

  • [2024-12-20 04:43:02]
  • 评测
  • 测评结果:AC
  • 用时:1004ms
  • 内存:4240kb
  • [2024-12-20 04:43:01]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define x first
#define y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)

typedef long long ll;
typedef double db;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<db, db> pdd;
typedef pair<ll, ll> pll;

const int N = 5e3 + 47;
vector<int> g[N];
bool vis[N];

int solve()
{
	int n;
	string s;
	if (!(cin >> n >> s))
		return 1;
	
	map<char, char> op;
	op[')'] = '(';
	op[']'] = '[';
	op['}'] = '{';
	fill(g, g + n, vector<int>());
	FOR (i, 0, n - 1)
	{
		int a, b;
		cin >> a >> b;
		--a;--b;
		g[a].pb(b);
		g[b].pb(a);
	}
	
	int ans = 0;
	auto bfs = [&](int v) -> void
	{
		queue<pair<int, string>> q;
		q.push({v, string(1, s[v])});
		fill(vis, vis + n, false);
		while (!q.empty())
		{
			auto top = q.front();
			q.pop();
			int u = top.x;
			if (vis[u])
				continue;
			string str = top.y;
			if (str.empty())
				ans++;
			vis[u] = 1;
			for (int to: g[u])
			{
				if (!vis[to])
				{
					char c = s[to];
					if (!op.count(c))
					{
						q.push({to, str + s[to]});
					}
					else
					{
						if (str.empty() || str.back() != op[c])
						{
							vis[to] = 1;
						}
						else
						{
							string nx = str;
							nx.pop_back();
							q.push({to, nx});
						}
					}
					
				}
			}
		}
	};
	
	FOR (i, 0, n)
	{
		bfs(i);
	}
	cout << ans << '\n';
	
	return 0;
}

int32_t main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int TET = 1e9;
	//cin >> TET;
	for (int i = 1; i <= TET; i++)
	{
		if (solve())
		{
			break;
		}
		#ifdef ONPC
			cerr << "_____________________________\n";
		#endif
	}
	#ifdef ONPC
		cerr << "\nfinished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec\n";
	#endif
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3580kb

input:

4
()()
1 2
2 3
3 4

output:

4

result:

ok single line: '4'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

4
[[]]
1 2
2 3
3 4

output:

2

result:

ok single line: '2'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3788kb

input:

6
([]{})
1 2
2 3
3 4
4 5
5 6

output:

4

result:

ok single line: '4'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3764kb

input:

2
()
1 2

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3484kb

input:

2
)(
1 2

output:

1

result:

ok single line: '1'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

2
[]
1 2

output:

1

result:

ok single line: '1'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3472kb

input:

2
][
1 2

output:

1

result:

ok single line: '1'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

2
{}
1 2

output:

1

result:

ok single line: '1'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

2
}{
1 2

output:

1

result:

ok single line: '1'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3788kb

input:

3
())
1 2
1 3

output:

2

result:

ok single line: '2'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3792kb

input:

3
)((
1 2
1 3

output:

2

result:

ok single line: '2'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

3
[]]
1 2
1 3

output:

2

result:

ok single line: '2'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3468kb

input:

3
][[
1 2
1 3

output:

2

result:

ok single line: '2'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3504kb

input:

3
{}}
1 2
1 3

output:

2

result:

ok single line: '2'

Test #15:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

3
}{{
1 2
1 3

output:

2

result:

ok single line: '2'

Test #16:

score: 0
Accepted
time: 995ms
memory: 4008kb

input:

4999
))(())))()(())(()(())())((()(((())())))((()(((()()))(())(())(()(((()((()((()))))()))(()(()))((())()((()(()))())()(()(()()(()()()))()((((()())(()()))(()))))(()((((()))())(())(())()()))(((()())())((((())(())(()()()(()())()(())()))(()(())(((())()()(((())(()()(())(()()))(())((()))(((()))))(((()()((...

output:

2499

result:

ok single line: '2499'

Test #17:

score: 0
Accepted
time: 988ms
memory: 3980kb

input:

4999
[][][]]][[[[]]]]]][][[[][][]]]]]][[[]]]]][[[[[[[][[][[]][]][][[[[]]]][[]][[]][[[[[[[]]]]]][]][[[][]]][[][[][]]][]]][][[[][]][][[][][[]][]]]]]]][[[[]][[][[]]][]]]][[[][]]][]]][[][][]][][[[[[]][[[[][]]][][[][[[]][]][[[]][[][[][[[[[]]]]][[][]]]][[]]][][]][[[]]][[][]]][[[[[[[[[[][[]][[][][[[[]]][]]...

output:

2499

result:

ok single line: '2499'

Test #18:

score: 0
Accepted
time: 999ms
memory: 3948kb

input:

4999
}}{{{}{{{}{{{}{}{}}{{{}{{}{}}{{}}{}}}{}{{}{}{}}}{{{{{}}}{}}{}{}{{}{}{}}{}{}{{{}}{{}{{}}}{}}{{}}{{}{}{{{}}{}{}}}{}{{}}{}}{}{}{{}{}}}{{}{{{{{{{}{{}}{{{}{{}{}}}{{}}}}}}}{{{}}}}{}{}{}}{{}}}{{}}}{{}}{}}}{}}}{}{}{{}}}{}{{}}}}{{{}{}{{}{}{{}{}}}}}}{}}{{{}{}{}}{{}}}}{}}}}{{{{}{{{}{}{{{{{}}{}{}{}}}{{{{}{...

output:

2499

result:

ok single line: '2499'

Test #19:

score: 0
Accepted
time: 541ms
memory: 4032kb

input:

4999
(())(())(()())))((()()))(())((((()(()((())(((()())))((()))()(((()((((()))(()()))(()))))((()))(())))())(((((())()()())((()((()()))()()((())(()()))(())((())((()()()(()(((()(())))()())))(()))))))((())(()((())))(())((((())(((()()((())())(())((((())()())((((((()))(()(()())))))))))(())))(((((()))))))...

output:

6247500

result:

ok single line: '6247500'

Test #20:

score: 0
Accepted
time: 525ms
memory: 3844kb

input:

4999
][][[[][]]][[[][[[][[][][]]]][][[[[[]][[][]][][][]]]][]]][][]]][[[][][]][]][]][[]][[][[[]][]][[][[][[]][][[[[]][[]]][[[[]]]]][][][][[][]]]]][[[[]][]]]][][][[][[[[[]][]]]]]]][[][[][[[[[][[]][]][[][]][]][[]]]][[[][[][[[]][[[][[[][]][[][]]][[]][[][]]][[]]]][[][[[[[][]]]]][][[]]][[[[]][]][]][][[][[...

output:

6247500

result:

ok single line: '6247500'

Test #21:

score: 0
Accepted
time: 536ms
memory: 3804kb

input:

4999
{}}}}}{{{{{}{{{}}{}}}}{}{{}{{{{{}}{{{{{{{}{{}{}{{}{}}{{}{{}{}{}{{{{{{{}}{{{{}}}}}}}}{}}{}}{}}}{{{}{}{}{{}{{{{{}}}{{{{}}}{}}}}}}}{{{{{{}}}{}{{}}{}}{{{}{{}}{}{{{}}}{{}}{}{}{}}}}}}{}{}{{{}{}{{}}}{}}{}{{}}{{}{{}{}{}}}{}{}{}{}}}}{}}}{{}}{{}{}}{}{}}}{}{{{}{}}}{}{}{}}{{{{}{{}}}{}{{{}{{{}}}}}{{}}}}}}{}...

output:

6247500

result:

ok single line: '6247500'

Test #22:

score: 0
Accepted
time: 3ms
memory: 3864kb

input:

4999
]]][])]))())[([[[([)(([(][]](([([[)()]([)[(()))])))[[)([())([(((]((([(]))]][(]]))(]()(([())([[()])]))([[)]))))][[[(]()[)[)[[])[)]])(])))))])((][)][[)][()[[[]]))[()[()(()]([(])[()]()([)]](]])[(]]))))]][[])[]()][][[[[[[(()]([([])]]))])())]()(](]))]]])][[))][)[([]([(()][])])][]())[(]]))[][(])])()[...

output:

1698

result:

ok single line: '1698'

Test #23:

score: 0
Accepted
time: 3ms
memory: 3784kb

input:

4999
}))){{}))}({{{{}})({(({)}{{(}}}{((}}()(}{{{{()})}({{){)}(})){{}(}(((}(){(}{)}){()}{(})((((){((){(({{}))}(({({}(}(){{({}{{({()}})})(}}{{(}()(}}}(({{)(}}){()))((){{}(){}}{(((((}){()(){}{}((()(}{{{()))}{{}{())()}}(((}}){}(}}})){(}()({{(({{())}}))})(){{}{)}(({))}{{){}}}{}{)}{({((((((()){})(}{}(}}})...

output:

1768

result:

ok single line: '1768'

Test #24:

score: 0
Accepted
time: 3ms
memory: 4016kb

input:

4999
[{[]{]{{]{}}]}]{}]}}}[[[]}}]{{[}[{{{{{[{}[[[{{][[}{[[{}][]{]{{[{[{]]}{}}[{}]}}{[]{]}}{{{}]{{}{}][}[}][}}}][}}]]][}}}[}[]{}}}]{}{]{}}[][][]{[]{}]}}]{[[[{}}{]}[{]{{][}[}]]}[[}]]}{}[]]}{}{}[}[]]][{[}[{[][{}}[]{}}}{}[[]{}[[}[{}]{{{{{[}{}]]{}}}}}}[{}{[}]}{[}}{{[]}]][[[}]}}}}]}}{[]}}[}]}[{}[[[{{[[{[{...

output:

1779

result:

ok single line: '1779'

Test #25:

score: 0
Accepted
time: 2ms
memory: 4072kb

input:

4999
}}()(}(]({{(]()]}](][)()]}[[]}{[(}({{)([}){{{]))(]{{()){)]((}(]){(()[[][((][}[}{]})][{}(]({)))[{([}[[[){[)[}[{])[{)]()}]})((({)}]){{{(}}}{[(]}}][}}{}{{][(}}]][[(){]]}[[)}{]}}}(}){)[([[((}))[)){(}{){]([(][(}]}]]{}[[{{{[[)))([]}[)})[)((}()}{]({]]{{}[{[([}]{{[{)){{)))[}]}]}]]))[[)[]]]][{)]]}][}[}[...

output:

993

result:

ok single line: '993'

Test #26:

score: 0
Accepted
time: 575ms
memory: 3996kb

input:

4999
))()()))((())())((())((((()()()((((()()())))((()()(())((()))())))(())()()()(()(((((())()))())))))())()((()()()(()((()((()(())()())))))()()())()))))()(()())((())))))))()(())()(())()(()()(()))))))))()(())))()()((((()(((((()())((()(((()(()(((()((()(((())))((((()()()()()(())(())((()(()())()()()((()...

output:

6194370

result:

ok single line: '6194370'

Test #27:

score: 0
Accepted
time: 564ms
memory: 3972kb

input:

4999
[]][[]][][[][][[][[]][]]]]]][][]][[[[[[]]][[][[[[[[][]][]][][[]]]]]][[][][]]]][[][[]]][[][[[[[[[[[[][[[[]]][[[[][[[[][][[][[[[[]][[[[][[][[[[]]][[[]][[[[[[[[[[][][][]][[[][[[][[[[][[[[[][[][[]][[][[[[[[][]][[[[][[][]][]][][[][][[[[][[[[][][[][][][[[[][][]][]][[[][[]]]][]]]]][[[[][][[[[]][][[[[[...

output:

6194370

result:

ok single line: '6194370'

Test #28:

score: 0
Accepted
time: 581ms
memory: 3956kb

input:

4999
{{{}{}{}}{{{{{}{{{}}}}{}}{}{}}{}}{{}}{{}{{{}{}{}}}{}}{{}{{}{{{}}}{{{}}}{{{}{}}}{{}}{}}{}{{}{{{{}{}}}{}{}{{}}{{{}{}{{}{{}}{{{{}}{}{}}{{{}}}{{{{}}{{{{}}{}}{{{}{}{}}}{}{{}}}}}{}}{}{{}{}}{}{{}{{{}{{{{}{{{}}}{{{{}}{}}}}{{{}{{}{}{{{}}{{{}{}{{}{{{{{}}}}{}{}}}}{{}}}}{}{{{}{}}}{{}{{{}{{}{{}{}{}}}{{}{{}}...

output:

6194370

result:

ok single line: '6194370'

Test #29:

score: 0
Accepted
time: 687ms
memory: 3868kb

input:

4999
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((...

output:

6320

result:

ok single line: '6320'

Test #30:

score: 0
Accepted
time: 677ms
memory: 3840kb

input:

4999
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[][[[[[[[[[[[[[[[...

output:

6320

result:

ok single line: '6320'

Test #31:

score: 0
Accepted
time: 689ms
memory: 4164kb

input:

4999
{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{...

output:

6320

result:

ok single line: '6320'

Test #32:

score: 0
Accepted
time: 10ms
memory: 3792kb

input:

4999
]][[][][[[)([)](([)))][([)([[(]])[[[)))))[))])]((]]([(()()([()[])][([[)([][)][]]((][[((]][))[()())[)[[([[(])]()()[][])])))[([][)]([]]][])())[]([])(]]()((]][)[())[)])([(((((((][(])])(]][))()(][]())(][)[][[)((])((]])[)]()([[[((]]])[])(][))[[))(([[((])]()()])][))[(][[[]))])])][((((][(()][[]][[(((]...

output:

2973

result:

ok single line: '2973'

Test #33:

score: 0
Accepted
time: 21ms
memory: 3868kb

input:

4999
}{){)}{({((()(}{)}){)(}()(}{}{){){}({({}(){){}}{)(((){{}})}(({{({}})){)))})())}}}}}{)(}(){}{{))})}{}((({{}()({}){}{}{{({{(}))}()}()){)(}{}))}})){({)}})}((}}{{)}(({))(((}}{(}{}}}{()(}){})())}()){(}}{)}(}}})(((}}(}{(}{}{)({()){})}))(}}}(}}})})}}((}){{{)(}{}{{)}){(({}{)(){(}{{}({)({}({{{{(}))({)(}...

output:

3382

result:

ok single line: '3382'

Test #34:

score: 0
Accepted
time: 16ms
memory: 3808kb

input:

4999
{[]][][[{]{[{]}{}][]}{]}{}[]]{]{{[{}}]{}{}[]{{}[]{[][{][[]{{[[[]{}}{][]{}}{]}}]][}}]]{]}{{}}}]]}{[]}}}]][[]}[}{}]{{[]}{][{[[[]]}}]}{}]]}]]}]{{}{]}[[}}]}{{}]]{]}}{[{{[}}{}[[][}}]}[}][][][[]}]}[]]{]{[][[][{}}]{{{]{]{]}{[{}}]}[{}]]][{{[{[}][][{{}}[{{}{{[[]{[][[}{[[]{[][]][[{{}{}{{}{][[[][}[{]]{}[]...

output:

3066

result:

ok single line: '3066'

Test #35:

score: 0
Accepted
time: 7ms
memory: 3748kb

input:

4999
{[{[)}([}[(}[()((][(]}])){(}()})[()[}{{}[(([)[}[[]({}[])}{(){(}}][{[[{[{){[[)){](}[)[()[][(}}(}}((]}))[)(])){]{){((}}]{{)}]}[{([{)[()}]}[[{])([}([{(}))[{(([([[]})[)([)[(((])}])[{{[)))({){{(}{({]{[[(){]{[}{]]{[((})]][{[(}{[))][]}{[]){{(])){}]]}{(}(([}[){[([]][[(]()}[(}][}[)([({}{{])[[]([[])}})]{...

output:

1207

result:

ok single line: '1207'

Test #36:

score: 0
Accepted
time: 504ms
memory: 4000kb

input:

4999
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((...

output:

4998

result:

ok single line: '4998'

Test #37:

score: 0
Accepted
time: 521ms
memory: 3920kb

input:

4999
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[...

output:

4998

result:

ok single line: '4998'

Test #38:

score: 0
Accepted
time: 532ms
memory: 3892kb

input:

4999
{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{...

output:

4998

result:

ok single line: '4998'

Test #39:

score: 0
Accepted
time: 595ms
memory: 4032kb

input:

4999
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))...

output:

4998

result:

ok single line: '4998'

Test #40:

score: 0
Accepted
time: 574ms
memory: 4028kb

input:

4999
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]...

output:

4998

result:

ok single line: '4998'

Test #41:

score: 0
Accepted
time: 572ms
memory: 4176kb

input:

4999
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}...

output:

4998

result:

ok single line: '4998'

Test #42:

score: 0
Accepted
time: 810ms
memory: 3916kb

input:

4999
)])][((())(()()(]]())(]]))[([[)][]()(][[[][[)[[][)(([(]([([]]())](([])([][[])][)()(]])[[[(])()[)]))))))(((])(]([([))](]()](])(][[)[[(()(](](][][[(([](([[[[])(])[((]]([))(([(]][](]()]][]]([(]]])))]))[)([]))])])))])(][[]]([]))]([)[[()](][[])))[][(]((()[[][)(](()([))(]([[)()[])[]]((([](([]]())[[](...

output:

1239

result:

ok single line: '1239'

Test #43:

score: 0
Accepted
time: 105ms
memory: 4176kb

input:

4999
{)}{)(){}}(}}}(){(()}(())(()((}{{((){)}){({(}{)}}}}}}{}})(}({(}}}}({{{(}){{)}{({})(}){}}){))()}}(){(}{{}}}{((()(}()(}}()}}))(({}))})({)(}{{}{{){){))()({)(}{(}}}}{({)()))}()({}()}((}(}})}{){{}{{)(}({}}}({({())()}}){)}}{){(}{(})){{{){}{()}(({{}}}}}({{{}}{})(})}}{))){((}){)}}}){{)({)({)){{)(}{{)}(...

output:

1230

result:

ok single line: '1230'

Test #44:

score: 0
Accepted
time: 104ms
memory: 3904kb

input:

4999
]]]]]}{}][{]}]{}}]}{]}]}[[[{{]][{}[{{{{}{[][]}}{]]][{]]}[[{}}{[}{[{]{{{]{[{]{{][][][]{][{{[]][}{]{[][]}[}[}}[{{{]}{[{[]{[}{]][{[{}{}}{{][{]]]]]][{}}{}}[]{][}]]][}[[]}{}]}{}]]]}]{[}}{]}]][}{]}}{]{[{}}[][{]]}}}{{]][}{{}[{[}][{[]}}}[][{[[]}}}][]}]{[}}}]]}[[{{}{[}}]{{][]}}[}}]{][{{[}}[]{[[[[[]}]}}[...

output:

1272

result:

ok single line: '1272'

Test #45:

score: 0
Accepted
time: 776ms
memory: 4016kb

input:

4999
)}{)}{{}[(}]])(][(}()()}[[{}){(]([}}]{({])[}){{})(]{)[})[{})][)[[}{]{)}{)})){})([([)(}{)()}{]](}{[(}[]({)}[[({{])([[])(]{][]([[}({[({)(]{){([]){{(](}]]({[}{(}[[}]{]{]]}[}[)[}{[)]](([{[}]]{}})))){]]({((]}(]}(()))]([}()[))(){{(]{((}[}]]{}[)[[)[([}]}[[[)))}(})(]{(}))]{{}][[(())(){]]([[][]))])(}]]]...

output:

842

result:

ok single line: '842'

Test #46:

score: 0
Accepted
time: 307ms
memory: 4056kb

input:

4999
()()())()()())()((()(()((()))(()(())((())())))(()))((()(((())()(())))()))(()())(())())))()()())()()()))()))()))())))())((())()()()(()()))))(()())))))))()))))(((())(()))))((((())()))())))(()((()))())))()())(()))(()())(()())))()((((((((()())))))())(())()((()))()())()((((())())))()(())))))()))(())...

output:

6242503

result:

ok single line: '6242503'

Test #47:

score: 0
Accepted
time: 298ms
memory: 4060kb

input:

4999
[[[][[][][[[]]][]]]][][]]]][[[[[][]][[[][][]]]][[][][[[[[][[[[[[]][[[]]]][[[][[][[[][[[][]][]][][][][][][[][[[][[[[[[]]]][][]][[]]]]]][[[[]]]][[]]]][[[]][]]]][[][][[][][[]][[[[[]][][]][[]][]][[[]][]][][]]]]]]]][[][][[[]][[[[]][[]]][[]][][][]]]][[[[[]][]]][[[][[][[[[[]][]]][[]]]]][[[][[][[]][[]]...

output:

6242503

result:

ok single line: '6242503'

Test #48:

score: 0
Accepted
time: 281ms
memory: 3964kb

input:

4999
}{{}}}{}}}{}}{{{{{{}}{}}}{{{}}}{}}{{{}}{}}}}{{{{}{}{}{}}}{{}}{}}{}}{}}}}}{{}{{{}}}}{}}{}{{{{}{{}{{}{{}{}{{}}{}}}}{{}}{}}}{}{}{{{}}{{}{}}}{{{{}}}{{{}}}{}{{}{{}}}}}}{{}}{{{}{{{{{{{}}}{{}}{}}}{{{{}{}}{{}}{{{}}{{{{{{{{}}}}{}{}}}{}}}{}}}}{{}{{}{{{}{{}{{}{}}}{{}}{{}{}}}}{{{}}{{{{{{{}}{{}{{{{{{}{}{}}{...

output:

6242503

result:

ok single line: '6242503'

Test #49:

score: 0
Accepted
time: 295ms
memory: 4212kb

input:

4999
)))(()(((((()))(()))(()((((())))((())()))(()()(()))()()()((()(((()()))(()(())))))())((()()(()))(())((()())()(())())(()(())(())())((((()(()())((((((())))))))())(((((())()())))()()(((((((()))((()))()()()(())()()(()()())())())()()()(())())(())))((())((()))))()(()((()))()))()(()((()()))())))()))(()...

output:

6242503

result:

ok single line: '6242503'

Test #50:

score: 0
Accepted
time: 293ms
memory: 4016kb

input:

4999
[]]][][][[[][[[]][[][[[][[[]]][[[[][]][[][[[]][][][[]][]][[]]][]][][][[][][][[[]]]][]][[]][[][]]]]][]]][]]][[[[[[][][[][[]][[][][]][][]]][][][][][][[][][[][[[[[[[][[][][[][][[[][]]][[][]][[]][[[]]]][[[]][[[[][[][[]][]][[[[][]]]]][]]][]]][]]]]]][]]]][[[[[][]][][[]]]]]][[[[[[[]]][[]]]][[[][][][][...

output:

6242503

result:

ok single line: '6242503'

Test #51:

score: 0
Accepted
time: 313ms
memory: 4236kb

input:

4999
{{}{}}{{{{{{{}{}}{}}{{}{}{{{}{{}}}}}{}}{}{{{{}{}{}}{{}{{}{{}}{}}}}{}}{{}{}{}{{}{}{}{{{{}}{{{{}{{}{}{}{{{{}}}{{{}{}{}{}{}}}{{}{}{{{{{{}}}}{}{}}{}}}{}}{{{{{{}}}}}{}{{}}}{}{{{}}{}}{}{}{}{{{{}{{}}{{}{{{{{}}{{{{{{{}}}{{}}{{}{{}}}}}}}}}}{}{{{}{{}}{}}}{}}}{}{}}{}{}{}}{}{{}}}{{}{{{}}{}}{{}{{{{}}}{}{{}}...

output:

6242503

result:

ok single line: '6242503'

Test #52:

score: 0
Accepted
time: 551ms
memory: 4240kb

input:

4999
(())(()(()(())(()((((())(())))(()(((())()))))(())()())))((()(((((()))(()((()()()))))))(()()()))((((((()()))()()(()(((())(((()))))))())((((()()())))())()(((()()))))((()()((()())((()(()))()()()(())))))((())()()()))()((()()())())()(()())())()(()))))((()(())((()(()(())())())((())((((())(((())))((((...

output:

6247500

result:

ok single line: '6247500'

Test #53:

score: 0
Accepted
time: 564ms
memory: 4040kb

input:

4999
[]]]]][[]]]]]]][][[[]][]][][]][[[][]][[]][][[[]][[[[]]][][[]]][[[]][][[][][]]][][[[[]][]]][[[][[]]]]][]][][]]]]]]]]][[[[]][[][[]][]][][][[[][][][][[]]]][]]][]][[]][[][[[[[[[[][][[[]][[][][[[]][[][[[][[]][[]]][]][][[[[][[[[][][]][[[[[[[]][]]]]][[][[][]]]]][[]][]][[]]][]][[[[[[][[[][[]][[]]][[[]]...

output:

6247500

result:

ok single line: '6247500'

Test #54:

score: 0
Accepted
time: 597ms
memory: 4016kb

input:

4999
}{{{{{{{{{}}{{}{}{}{}{}}}}{}{}}{{{{{}}}}{{}{}}}{{{}{}}}{}}{{}}}}{{}{}}{{{{}{{}}}{{}{}{}}}{{{{{{{{{}{{{}}{}}}{{}}}}{}}}}{{}}}}}{}{{{}}}}{{{}{{}}{}{{}{{}{}}}}{}{}{{{{{{}}{}}}}{{{{}{}}{}}{{{}}{}{{{}}}}{{{}}}{}}}}}}}{{{{}}{{}{}{{}{{}{{}{{{{{}{{{{{{{{{}{{}}{{}{{}}{{}{}}{{{{{{}}}}{{{}}{}{{{{}}{{}{{{{...

output:

6247500

result:

ok single line: '6247500'

Test #55:

score: 0
Accepted
time: 588ms
memory: 3948kb

input:

4999
))())((())()()(((())()())))))()((())))())())(()((())((()(((()((()(())()()((())()())(()()()()((((()(())))(((((((()))((())((()))(((()())(()))))()))((((((()()(()))))())(((())(()))(())()())(()))()(()()(()()))))()()()(((()())(()(((())))()()()()())))((()))))))(()()))(()(((())()(()())(((()())()())))))...

output:

6247500

result:

ok single line: '6247500'

Test #56:

score: 0
Accepted
time: 579ms
memory: 4212kb

input:

4999
][[[[[[][][][[][[]][]]][]][[[[][[[[[[[[]]][][]][]]][[]]][[[]][][[[]][][][[][[][[]]]]]][[][[]]][]]]]][][[]][][[]]][[[][[][[][]][][[[]]][]]]]]][[[[][][]]][]][[[]][[][][[[][[]][]][]]][]][]]]][][[[][[][]]]]]][[[]]]][[]][]][]]][[]][[][]][[]]][][[]][][[][[]][]][]]]][[[[][[[[]]][]]][]]]]]]][[][]][[[][...

output:

6247500

result:

ok single line: '6247500'

Test #57:

score: 0
Accepted
time: 568ms
memory: 4016kb

input:

4999
}}{{{{{}{}}{}}}}}{}}}{{}}{}}{{{}{}{{{{}{{{{}}{{}}{{{}{{}}}{}{{{}{{}}}{}{}}}}{{}{}}}{{}}{}{{}{{{}{}{{}{}}{}}{}}}}}{}}{}{}{{{{}}{}}}}{}}{}{}{}}{}{}}{{}}}}{{}{{}}}}{}}{}{{{{{}{}{{{}{{{}}{}{}}{}}{{}{{}}{{}{{}{}{}}{{}}{}}{{}}}{{{}}}}{}}}{}}{}{{}}{{{{{{}{{{{}{}}{}{{{}}{}}{{}{}}{{}}}}}{{{{{}{}{}{{}}}}...

output:

6247500

result:

ok single line: '6247500'

Test #58:

score: 0
Accepted
time: 49ms
memory: 3912kb

input:

4999
)[([[)[([)[([(][]][](]]][((]](([(]](())]([(][)][)[[(](](()[)[([([([)[)[[)[][[[]]])))]]][[((]]]]][[[(())((]]())(()](]([))]])]))]()[([)]][])][([[))([[)][)(([)(][(]))]])[[)))[])[]]((][)[][[)(])(]][]))))[])]()()))]][(]()([([](]][())[(]))([)))[[)(](])(]))([])]](]))([[(]][][((][])[[]))[((][))]]])[)][...

output:

1209

result:

ok single line: '1209'

Test #59:

score: 0
Accepted
time: 461ms
memory: 4180kb

input:

4999
})({){{)}{{)}}{{{()}(}()){(}{){}{)(}{{()((({)}}){()}}(()}}{(({()((}}(}()))}})())}{()}){)((()}()))}}){}{}(})(}{)))({{{{){}{}()}(){}())(({}{}((}((()({}})}{{{(){}{}{{}}(}{}{{}}}}}}({}}({)}}}{}))((}{))({})}}()))(}}{({((}}{)})(()})))(}()(}{({)({{)))()())}{{})}()){})()}}})}{()})})()}({}})({}()))(})(}...

output:

1175282

result:

ok single line: '1175282'

Test #60:

score: 0
Accepted
time: 49ms
memory: 3968kb

input:

4999
[[]{[}}{}{{]}[[}{}]}}]]]]}{}[{]}}[}][}]{}{][{[]{]]}}{}[}[}{[{]][]{}[{[[]}}][}{]][{]{[[]]}[[}}]{[}{}{}[}{[]{]][}[[}{}}]][{{]}{}[{]]{]]{[[[}[[{]}]}}[{}]{}}][]]]]{[[}[}{]}{{]{}[[{}{[}]}]}{]{{}[}[]][{][[{[{}]{[}[{[][][{]{}}}}}{[{}{{[]{{}]}[{[[[]{{}[{]}{{]{]]}[}}]]{[]{{}{{]]}[}]{}{][{}}[]{[{{]{{[[{}...

output:

1220

result:

ok single line: '1220'

Test #61:

score: 0
Accepted
time: 239ms
memory: 4020kb

input:

4999
([{(([{(}}{(({)]{([())))[){[[({])()](}](](}[]}}{{(]]{[([[)(]}[([({){([}[)}]}])))]]}([[}][{){(]{(][[)][]}](}{)}){{(}}}(}[[[]((}}){(](}([{([]]]][)(](}(([()}{{[{]{[}}[){([())[{{{}[[[}][(){]}}{)(]][{}]}({([]){](]}((}]])[[]]}[{{})]()[]]}{){}})}()(({(}])[]{}])[}]()[}({}){}([]})]]([{({{{][[{({}}{[}{{]...

output:

183371

result:

ok single line: '183371'

Test #62:

score: 0
Accepted
time: 1000ms
memory: 4068kb

input:

5000
()())(((()(((()()(()()))(()((((()))((((())))()(())(()(()((()))())(()(())())())(()()()((((()))))()()))())()(()()(()(()(((((()(()(((()(((())((())((((((()(())())))((((())()((()()())())(((()))((()))()((()()()())())()))())))(()())()()())((())()))(())))))(((()(()((((())()()())())(()(()())))))())())((...

output:

2500

result:

ok single line: '2500'

Test #63:

score: 0
Accepted
time: 1004ms
memory: 4048kb

input:

5000
[]][][[][[[[[]]][[]]][[][[[]][[]][[[[[][][]]]][[[][]][[[][[[[][[[[[][[]]][][][[]]]][[[[[]][][][[]][]][[[[[[][[[[]][[[[]][[[[][][]]][[[[[[[]][]]]]][[]]][][[[[]]]][]]]][][][[]]][[[]][]][]][][][][]]][[]][][][][]][[]][[][[]]]][[][[]][][]][[[]][[][[]]]][]]]][]][][[[][[[][][[[[][[][][]][]]]]]]]]]][][...

output:

2500

result:

ok single line: '2500'

Test #64:

score: 0
Accepted
time: 999ms
memory: 4224kb

input:

5000
{}{{}}}{}{}{{{{}{}}{{}{}}{}{}{{{{}}{{}}}{{}}}}}}}}{}}{}}}}{}}{{}{}{{{{}}}{{{{}{{{}}{}{}{}}{{{{{{}}{{{{}}{}{{}}{}{{}}}{{}}}{{{}}{{}}}{{{}{}{{{{{}}}}{{}}}}}}}}{{}{{{}}{}{}{{{}{{}{}}{}{}{{}{{}}{}}{{}}{{{{{}}}{}{{}}}{}{{}}}}{{{}}{}}}{}}{{}}}{{}{{{{{}{}{{}{}{{}{}}}{{}{}}}{{}{{}{{{}{{}}{{}}}{{{{{}{}{...

output:

2500

result:

ok single line: '2500'

Test #65:

score: 0
Accepted
time: 551ms
memory: 3764kb

input:

5000
)()))((((()))())()())))((((((())(())()))()))())()())(()(((()((()(())(()(()())(())))(()((())(()))((()())))(()())((()))()()))(((()()((()(())))))))()(((((()()((((())())(())))())))(()(()()()((()((())()())()))()(()())()(((()())((())()((()()(())))())))(()))(()))(()((((()))()(((()((()(((()((()((())(((...

output:

6250000

result:

ok single line: '6250000'

Test #66:

score: 0
Accepted
time: 529ms
memory: 3888kb

input:

5000
[]]][[[]]][]]]][][]]][[[][[[[][[]][[]][[]][]][[][[[][[[[[]][]]]]]][[][][]]][][][[[[[]][][[[]]][]][[[[]][[[][[[][]][[[]]][]][]][]]]][]]]]][[][[][][[[[][[[[]][[[][[][[[[]][[][][[][[][[[][[][[[]]][[[[][[][][[][][][]][[][[]][[[[][[]]][]][]]]]][[[]]][]][][][[]][][[][[][]][[][[][[[][[]]]]][[[[][][][[...

output:

6250000

result:

ok single line: '6250000'

Test #67:

score: 0
Accepted
time: 539ms
memory: 4072kb

input:

5000
}}{}}}{}}}{}}}{{{}{{}}}{{{}}}}}}}}{}}}}}{}{{{{}{{{{{}{{{{{}}}{{}}{}{{}{{{}{{}{{{{{}{{}}{{{{}}}}{}{}}}}{{}{{{{}{{{}}}{}{{{{}{}}{{{{{{{{{}}}}{{}{}{}{{}{{}}{}{}{{{{{}}}}}{{{{}}{{{{{{}}}{{{{}}}}{}}{}{{}}{{{}}{{}{{{}}}{}}{{}}{}{{{{{{}{}{}{{{}{}{}{{{}{}{}}}{}{{}{{{}}{{}{{}}{{}{}{}}{}}}{}}{}}{}{}{{{}{...

output:

6250000

result:

ok single line: '6250000'

Test #68:

score: 0
Accepted
time: 3ms
memory: 3800kb

input:

5000
)]])])(()([()[])[])[)[)[[)[(([[[))[(([((([)()])]])[[[[(([]([][[]))(((]])[[)[)(([)()[[]])(]]]][]]][([([[)][[][[(([[([]([[[))[]([])])[(][)()()(((([(([[)(][]]])([[]]]))]]]([[[[)))(][]](([())])[(]()[)))][(]([)])[])[(](](([])[[]([((][([)[)))]])(])]]]))([](([))(][))(())](])]([))])[)]))([((()][(])((](...

output:

1763

result:

ok single line: '1763'

Test #69:

score: 0
Accepted
time: 3ms
memory: 3828kb

input:

5000
{)())}){}{}{{{{}(){}(})})}})({)}{(}){})(}{}){{{}){){}{)({{)(){{}((}{(){())(){}{{{}((((}({){}))({)}}{(}))}({{{}(({}{{{()((}{{)}}){(}{({}}}}){{}{{({){(){)(()())}}})})({(){)}{)}{}))){{{)}{}{){}}){{(){)}}{(}()(({{){(})}(}}{)}{}{{()({){)}{(}{}){)(}()(())})){}}({{{}{}{{{(}}}(}})({((}}}){){(})}))(}(()...

output:

1718

result:

ok single line: '1718'

Test #70:

score: 0
Accepted
time: 0ms
memory: 3848kb

input:

5000
]}}}{}[]][[][[[}}}[]]{]{{}}}]}[[{[][][[][[{{}[}}[][}[{{{}{}}{[{}[[}{{{][}[{}}{]]}}[[]]]][}}[}}{}[}}}}[}]}]][}][[[}[}{[][{}[}]{[[[{][}[}[}[}][]]{[[[{]]}{}}[{}{[[[{}[[]]}}]]}}{{]{{]}}[][{[}[]}}}[[]]]]}]][]}}}}{]}}{]}]]][}]}}{[]{]]{}{]{{[[}}}}]}][{[[}}{}}[}}][}][}[}{][[{]}]]}[{][{[[{]]{[{]}]{}[[{]...

output:

1829

result:

ok single line: '1829'

Test #71:

score: 0
Accepted
time: 2ms
memory: 4076kb

input:

5000
){{)({)(]))[[)(}}){(][()}](]{))[[[[]({[]{))([))]{[[[}((]{{[](}(([]]}]]]))[){)({}]]]{(]}](){(({({{)({](}}()[({[])[[(]{((]])([})([()([)}(]]{{[){)])){{[[){](}])[(}{{}}{}[{{)[[){}[[()(}][])]{}]{)][[{)}([]}}][[)}{[]]{()]}({]{[})}[(}{{((]}}}}}[(]][{}[((]([)}[]{[}]{(}}}([}{{]}])}([((])][)}{][}(]]}}][[...

output:

1031

result:

ok single line: '1031'

Test #72:

score: 0
Accepted
time: 585ms
memory: 3880kb

input:

5000
()))))(()))((()(()(((()()()))(()()())())((()(()(((()()()())()))()(()))()())((()(())())))()()(((((()()(())(())()())(()())()())))()()(()(())((())())))()))(((()((()())(())())(()(((()(((())(())))()((()))(()()))()(()(())(((())(((())))(()())()()))(()(()(()()())())))(()))()((((())))()())(())())(((((((...

output:

6197100

result:

ok single line: '6197100'

Test #73:

score: 0
Accepted
time: 559ms
memory: 3904kb

input:

5000
]]]]][]]][[]]][][]]]][][[][[[[]]]]]]]][[[[][[][[[][]]]][[[]]][][]][][][]][]][[[[]]]]][[][][][[]]]]][]]][][][[[[[[[[][[[[[]][[]]]][[[][[[[][]]]]][][[[[[][]][[[][][][[[][][][[[][[[][]][[[][]]][[[[[[][][[[][[][][[[]][]][]][[[]]]][[]]][[][][[][[[[]][][][[[[][][[]]][]]]]][[[[[[][]]]]][[[][][[[[[][[[...

output:

6197100

result:

ok single line: '6197100'

Test #74:

score: 0
Accepted
time: 582ms
memory: 3908kb

input:

5000
{}{{}{}{}{{{}{{{}{{{}}{{{}}}{{{{}{{{}{}}{}}}}}{{{}{{{{}{{}}{}}}{{{{{}{{{}}{{}{}}{}{{}{}{}{}}{{{{{}}{{}}{}{}{}{{}}{{{{{}{{{}}{{{{{}}{{{{}}{}{{}{{}{{{{}}{{{}}{}{}{{}}}}{}}{{}}}}{{}{{}{}}}{}{{}}}{{}}}{}{}}{}}}}{}{{}{{{{{{{}}}}}{{}}}}{}}}}{{{{{{{}}}}{}}{{}{}}{}}{}{}}{{{}{}{{{{}}{}}{{}{}{}}{{}}}}{}}...

output:

6197100

result:

ok single line: '6197100'

Test #75:

score: 0
Accepted
time: 695ms
memory: 3888kb

input:

5000
(((((((((((((((((((((((((((((((((((((()((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((...

output:

6320

result:

ok single line: '6320'

Test #76:

score: 0
Accepted
time: 694ms
memory: 3876kb

input:

5000
[[[[[[[[[[[[[[[[[[[[[[[][[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[...

output:

6320

result:

ok single line: '6320'

Test #77:

score: 0
Accepted
time: 688ms
memory: 4160kb

input:

5000
{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{}{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{...

output:

6320

result:

ok single line: '6320'

Test #78:

score: 0
Accepted
time: 17ms
memory: 3860kb

input:

5000
[)[(]([[)[()[()(](]((())](([])[[)[][(])[([(][)(([[][)())()(([[[]][]]])([]]])(((([][][)[[()((]((])]][])](([([([])((]())))([)][)[()][(][((])][(])](])]]()])([][[[)](([[([[([[[]]]]))]()()[])[(])][)[[[][(])[[[[[)(()([]]](](((][]()[][))(][([[]))[)])])(])]())][((())]]]())]]([())))]]()()[)[)[[][([(((](...

output:

3919

result:

ok single line: '3919'

Test #79:

score: 0
Accepted
time: 10ms
memory: 3772kb

input:

5000
(()({)})))(){()){)}{{){((})(){)))({)){})}}(}}}))}(())(((({}{}{}(}}({}){{})({}(}}()}}{{)()){(()({{}{(}){})){))({}}(}}}}}}}(()()){()(}{}{{){}(){(}{}))))(}({{})({)()}{)()){}}({))((}{{){()})))}}({)(}{{)()})){(})({()({)}}())}})))())}({}){}))}}}{{({)({)({){({()}({)}{{)(()({({(){}}()}{(}({())){){)}({}...

output:

3419

result:

ok single line: '3419'

Test #80:

score: 0
Accepted
time: 9ms
memory: 4016kb

input:

5000
[{[}{{][[{}}{]{[}[]{[[]]}{[{}[]}[[]]}{{]{{}]]]}}}}]{[{{{[}]]]{}[[]]}{[]]}{[]]][]][}][}}]}}]]{[{][{{]{][[{]{[}[]{[]{{{]{{}[[[}][{]][[]}{]][[]{{{]}[[}]}[}{{{]]}{]}}{}]}{{}{{[]]{{][[]{{}}}{{][]}}{]{]}}][{}{]][[}}[{[]]}}{{{]}}{{{}}[}{{{[][}[][[}}{}{{[[{]{]}[{][{{][}]]{]{]{]{{]}[{[[[{}]{[{]{[{{}{{}}...

output:

3334

result:

ok single line: '3334'

Test #81:

score: 0
Accepted
time: 3ms
memory: 3768kb

input:

5000
))[[{]{{]({}(((]]}[}([[}}]}]{))))]][}}[)}})[[(}[({{({])(){([{}{][]))]{{][}[[}){]()){[{[([}}))}[](}}))(})}{{)){{{(}{{{[)]]])[([[{)(([])}[{{{}}({}))]}}))[([]][[][[)])}(}()({}{[]{)(]({((}){}{({)[({}[}[}((}[}}{[{}[][]]([)}[([}}}{[]}(})]{[])]{}}{}{}[(}}[[{[(}]([{{{)({]}[){}((){{{[)(](}(({][}]{]][][)...

output:

1336

result:

ok single line: '1336'

Test #82:

score: 0
Accepted
time: 528ms
memory: 4056kb

input:

5000
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((...

output:

4999

result:

ok single line: '4999'

Test #83:

score: 0
Accepted
time: 523ms
memory: 3996kb

input:

5000
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[...

output:

4999

result:

ok single line: '4999'

Test #84:

score: 0
Accepted
time: 539ms
memory: 4012kb

input:

5000
{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{}{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{...

output:

4999

result:

ok single line: '4999'

Test #85:

score: 0
Accepted
time: 589ms
memory: 4208kb

input:

5000
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))...

output:

4999

result:

ok single line: '4999'

Test #86:

score: 0
Accepted
time: 546ms
memory: 4028kb

input:

5000
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]...

output:

4999

result:

ok single line: '4999'

Test #87:

score: 0
Accepted
time: 591ms
memory: 3900kb

input:

5000
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}...

output:

4999

result:

ok single line: '4999'

Test #88:

score: 0
Accepted
time: 104ms
memory: 3908kb

input:

5000
[)]([][([]](]([)][][)[(]([(]]][(](()])[([](()[))]])]][]]](])[)([[(]([(]][[]][)[)]])[[([[](])])))()))[[)))))([[)[])(][[([(]])][))]))])((](([(](]))[)))[[[[)[]((([)[)(()(([](]]]))]]()[]()(])[)][)()][)[((]([]())][])[[))(]]()]]][[[[())))])])[([)[][([][[(][[([[(](()()[](()[][[)[[[))[[]])[[](([[[])((]...

output:

1246

result:

ok single line: '1246'

Test #89:

score: 0
Accepted
time: 103ms
memory: 3908kb

input:

5000
){{}{({)}))()}(})}){{()({{{}))(})()(}}{}){{)}))){{){)()}}}}(({}})}{}{)(})))({({)))(}{({()))}}{()({{((})}))})}})}){}}}){()((}{){(()(}}(}{}{{{){}{{{())(({()}())()}))}}){()}}(}}}{})))})){({})}(}{}{{})}{(}))}){}{}{(){}(({(}}))({()()({{)((}}{({{({(){{)(()(({{({{(}{}{}()}({)}({(){{})){(){{())({}(){{}...

output:

1207

result:

ok single line: '1207'

Test #90:

score: 0
Accepted
time: 98ms
memory: 4144kb

input:

5000
}}{[{[[][{]{}[{}[]}[}{}]}}}[}}{{]}[}][}{}[[{[]{}]}]}}]{}]}]][[[]{[}}{}}{}}[[{{]]][{[}{[{{}{}}}{]]{[]]][[{{}[]{}{}{{[{]}{{}[]]]{}}[[]}}[}[{{]{}]}[}}[[]}}}{}{]{[{}{[}]{[}]}}}{}]][}{}}{]]]][{][{[{{}}]]{}}]]{]{[}[}[[[]{{}}}]}{}[]}}{}[]{[[{}]}}{][]}}[[[][][{[}[{{]]][]{}{}[}]}]}{{{{}][{{}]}[]]]][[}}{...

output:

1230

result:

ok single line: '1230'

Test #91:

score: 0
Accepted
time: 774ms
memory: 3936kb

input:

5000
}(][(}[)]})]]({))[}]{([{{)}{([}[){[][({][{}}[[][)}[))[)}]}{((]{[})](([[)[])}{[[{]][}{)]}]}]}]}{{]))][{}){}{})])((}))](]}}))()[)](([[[))]}[[{[][][())[(](}[{{)()}))}[][)]]}){({}]]](){([{})}((({}]){]}{[}{(]([{[][)]}[{[]]]()[)]})[[[]{}](][)(]{[}[]{{[}()]](]]{[]}[]]]]([))([{()][}}][{}()({))](}[[{}()...

output:

890

result:

ok single line: '890'

Test #92:

score: 0
Accepted
time: 315ms
memory: 4032kb

input:

5000
)((())))()))()((()(())))))(()))(()()())((()(())))(()))(()))))))()(())))())(((()(())()((((()()()(())())(())((()(((()((((())(())))(()))((((((((()())())(())((((())(((())))((())))(()((((((()((())))((()((((()))((()))()))))()))())()))))))))()()(())))()))(()(((())())(((())()))))((())()()((()(())((()))...

output:

6245002

result:

ok single line: '6245002'

Test #93:

score: 0
Accepted
time: 296ms
memory: 3860kb

input:

5000
]][[[[[][][][[[][[][[]]][]]][[[][][]]]][[][][[[][[[[[[]]][[[][]][[]][[]][][]][][[]][]][[]]][][]][][][[[[]][]]]]]][[]]][[]][[[]]]][[[[[]]][][][[[[[]][[[]][[[[[[][[[[]][][[][]][][[[[[]][]]][][]]]]]][[]]]][][]][][[]][]][[][[[]][[][[]]][[]][][]]]][]]]][[]][]]]]][]][[[[[][]][]][[[][[]]]]]]][][[[][]]...

output:

6245002

result:

ok single line: '6245002'

Test #94:

score: 0
Accepted
time: 311ms
memory: 4180kb

input:

5000
}}}}}}{}}{{{}{{}{{{}{}{{}{{{}{}{}{}}{{{}{{}}}{}}}{{}{{{}}{{}{}}}}{{}{}{{}{{}{}}}{}}}}}{{}}{}{}{}}}}{{}}{}}{}}}{}}}}{{{{{{}{{{}}{{}}}}{{}}}}{{}}{{}}}{{}{{{{{}{}}}}{}}}}}{{}}}}}{{}}}}{}{}}{{{{{}}{}}{}}{{{{}{{{}{}{}{}}{}}}}{}}}{}{}{}{{}}{{}}}{}}{{{{}}}}{{}}{}}}{}{}}}{{{}}{{{{{}{}}}}{}}{}{{}}}}{{{{...

output:

6245002

result:

ok single line: '6245002'

Test #95:

score: 0
Accepted
time: 315ms
memory: 3968kb

input:

5000
)))()((()())()()()))((((())(())())(()))(())(((((((())(())(()))())()(((((()(()(()()))((()()))())))((())))(()(()))))(()())())))))((()))()()()((()(((())()()(((((())))()))))))(()(())(()))((((()()(((()())))(())((()((((()(((())())))))((())()))()()()))(()((()))()()(())((()((()))(())(((((((())()()(((((...

output:

6245002

result:

ok single line: '6245002'

Test #96:

score: 0
Accepted
time: 309ms
memory: 3972kb

input:

5000
[[[[][]]][][]][]]]][][]][[]]]][]]]]]][[]][]][[[]]][[[[][[[]][][]][[][[[]]]][[[][[][[[][[[][][]]]][[[[[]]]]]]][][[[[]][]]]][[[][][[][[]]]][][[][][[]]]][[[][]]][[[][][]]][]]][]][[[[[[[[][][]][[]][]][[[[]][][]][][]][[[[][[][][][]]][]][[][][[][][[[]][][][[]][[][[[[]]]]]][[[[]][[]][[[]][[][][[[][[[]...

output:

6245002

result:

ok single line: '6245002'

Test #97:

score: 0
Accepted
time: 303ms
memory: 3972kb

input:

5000
{{{{{}}}{{}}}}{{}{{{{{}}}}}{{{}}{{}{{}{}{{{}{}}}{{}}{}{}}{}{}}{{}{{{{}{{{{{{{{{}{}}}{{}}{{}{{{}{{}{{{}{}{}}}}}{}}}{{}{}}{}{{}}{{{}}{}}}}}{}}{}{{}{{}{{}}}}}}}}}{{{}}{}{}}{}}}}{{{{}}{{}{}{}{{{{{}{}{{{}}}}}{}{}}}}}}}}{{}}}{}}{{{{}{}{{}{{{}{{}{}{{{{{{}}}{}{}}{{}}{}}{}}{{}}{{{}{{}}}{}{}{{}{{{{{{{}{}...

output:

6245002

result:

ok single line: '6245002'

Test #98:

score: 0
Accepted
time: 571ms
memory: 4240kb

input:

5000
())))(()()())()())))))()))(()))()(()()())))()()()()(()((((())))))))(()(())))))))()(()())))(((()))))))))(())))))(()(())((()))((())(()(((((())()()((()()()())))))(())()))))()())((())(((()()()))(()())))((()()))())))())(()()))(()()))(((((()()))(())()())()()((((()((()()(()()())((((())(())()()())((()(...

output:

6250000

result:

ok single line: '6250000'

Test #99:

score: 0
Accepted
time: 546ms
memory: 3916kb

input:

5000
][]][[[][[][][[[[]]]]][][]][[]][][[[]]]][]]][[[[][]]]]][]][]][[]]]][]][][[[[[]]][][][][]][[[][[]][][][[[[][[][][]]]]]]][[]]][[][[[]]]][]][][][]][]][]][][[][[[[[][[][]][][[[][[][][]][[[][]][]][[[[[][[[[][]]]][[][[[[[][][[[]]][]]][[][[[]][[][[]]]][]]][]]]]][]][[]][][[[]]]]][]]]][]]]][[]][][[][]]]...

output:

6250000

result:

ok single line: '6250000'

Test #100:

score: 0
Accepted
time: 586ms
memory: 3996kb

input:

5000
{}}}}{{}{}{}}}}}}{}}}}}}}}{{}{{}}}}{{}{}{}{}{{}}{}{}{}}}{}{{{{}}}{{{}}}{{}{}{{}{{}{}{{{{{{{{{}}}}{}}}}{{}{}}{{{}{}}{{}}{}}}}{}}{{}}{{{{}{}{}{}{{}{}}{{}}}{{}}{{}{}}}}}}{}}{{}{{}{{{}{{}{{{}}}}}}{{{{{{}}{}{{{}}{{}{{}{{{{}}}}{{{{{{{{{{{}{{{{{{}{}}{{}}}}}{}{{}}{{}}{{}{{}{{{{{{{{{{}}{}{{}{}}}}}{{{{{{...

output:

6250000

result:

ok single line: '6250000'

Test #101:

score: 0
Accepted
time: 589ms
memory: 4240kb

input:

5000
))())((()()()())))))))((()((())))(())((())())()()()()))((((()()))))()((()(((())(((()))())))))()()()()((()))())()()()((((((()(((()))((()()))))(()(())())(()())((()))())))()())))))()(()()(((()()))(((())))((((((())(()()())(())(((((())((())((()((()(()(())))())))(((())()))(())))))())((()((()(((()())(...

output:

6250000

result:

ok single line: '6250000'

Test #102:

score: 0
Accepted
time: 588ms
memory: 4028kb

input:

5000
]]]][[[]]]]]]]]]][][[[[][]][]]][[[[[]][[[[]]]][[[]]]][][[[][[]][][[][][][[[]][][][][[]][[[[[][[[][][[[[[]][[]][][][[[][][]]]]][][][]][[][]][][[[]][][][[]][]]][][][]][[][[[[[]][][[[]][]][][][][][][[[][][][[[][[][[]]][[[][[[[[]][][]]][][]][[[[[[]]][][[][[]][[]]]][[[[][][[[]][[][]]][[[[][[[]][]][]...

output:

6250000

result:

ok single line: '6250000'

Test #103:

score: 0
Accepted
time: 586ms
memory: 4012kb

input:

5000
}{{{}{{}}}{{{{}}}}{}}{{{{{}{{{{}}{}{}}}}{}{{}}{}{{{{{{}}}{}{}}}{{}}}}{}{}{}{}{}{{{}}{{{{{}{{{}}{}{{{{{}}}}}}{}}{}}}}}}}{{{}}}}{}}}}}{{}{{}}}}{}}}{}}{}{}{{{}}}{{{{}{}{}}}{}}{}{}{{}}{}{}}{}{{{}{}}{{}}}}}{}}{}{}}}{}{}{{{{{{{{}{}}}}{{}{{}}{}{}{{{{{{}{}{{}{{{}{{{}}}{{}}}}}}{}{}}{}{}{}}}}{{{}}}{}{}}}...

output:

6250000

result:

ok single line: '6250000'

Test #104:

score: 0
Accepted
time: 451ms
memory: 3952kb

input:

5000
[][)))][))()][(([)())()))[[))]])[]][[[[](][[[([])([]))](]]([([(]())[])[]()[()]](((][)()(()(()[)])[)([(])[((]]([]])]]][)()([)))([([[][[([(]))[])))](])([(]()][]]]])][][)(](((([[)])][)](][)())][[(][(])][]((()[[)(]][[))]](]()](((]))[]()([][]()][()[[((()[)()[[)]))((()[(](](([)([(]([]))][)]]([][]()](...

output:

1181521

result:

ok single line: '1181521'

Test #105:

score: 0
Accepted
time: 270ms
memory: 4028kb

input:

5000
()(})()})({(}){)}{}(}}{(((({}{}{)((({(}}())}){()({})()({(}){)())})({{(())(}}))({(}{{)))){{})({()()(((}}}()()})}{}{}(}}(){)))(({{(()}({}{{)({)})()})}(()}({{})((){{((}{){}})(((}{}{)}()){)()){}({{)}))}}}{{{(})(){}){)))}{}}({)}}({({)({){)))}}}(({{{{)(({{(}})((()}{}{{{{()({}(}){{(}{{))}()}({({}(({((...

output:

402169

result:

ok single line: '402169'

Test #106:

score: 0
Accepted
time: 452ms
memory: 4056kb

input:

5000
{]][}}}}[{[]{{}{{}[}[{[{{]][{[[][]}}[}}}{[}}]]]{{{]}]}[][}][{[}{{{]}}}{[{]{{{}]][}[{[{][[][{]{{[{{}}{[}]]]{[]}{}{[[{{}]{}}[]]}[[[}[}]{[]{{][}{{}]{}}}]]{[}]{[}[}}{[{{[]{}}]}{]{}]]]}}[[}]]{[{{[][[[{]{{[}}{]]]{]}]]{{[[]{]}[[[][[{]}{[[][][][[}{]][[{]]}{]]{[}[[}]}}][}]{]}{[[[{[{{{[[}[{}}[]]]}}}[[}{[...

output:

1162482

result:

ok single line: '1162482'

Test #107:

score: 0
Accepted
time: 812ms
memory: 4000kb

input:

5000
((})]{)(})]{)((){[{)}([]{(][][})]{){}(]{[[}[)}}]]})}[[[)[]{]][]])])])}][[]})))](}][({}}({}]))]}}}]){][]([{}[)(])](})][}[})([]]){]({]{(()]])}{{]{}(}]]}({(]}[}}][({{([(}([()[][{{()([(]}[))({][{[[(]}{)]](}]]{]({{(}{((){[)))({[{()}}[]}]][){(}}][{)[{]{{{{{[[]}{]}[)([){{]}[{[})](({}[)((([][[[]]({{(}}...

output:

823

result:

ok single line: '823'