QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#823038#9052. Balanced Tree PathLaVuna47AC ✓225ms4512kbC++172.3kb2024-12-20 18:32:142024-12-20 18:32:15

Judging History

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

  • [2024-12-20 18:32:15]
  • 评测
  • 测评结果:AC
  • 用时:225ms
  • 内存:4512kb
  • [2024-12-20 18:32:14]
  • 提交

answer

/** gnu specific **/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/** contains everything I need in std **/
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(S) ((int)S.size())
#define FOR(i, st_, n) for(int i = st_; i < n; ++i)
#define RFOR(i, n, end_) for(int i = (n)-1; i >= end_; --i)
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef unsigned long long ull;
typedef long double LD;
typedef pair<ull, ull> pull;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

vector<vector<int>> adj;
string s;

bool is_open(char ch)
{
	return ch=='{'||ch=='('||ch=='[';
}

bool match(char op, char cl)
{
	return (op=='{'&&cl=='}') || (op=='('&&cl==')') || (op=='['&&cl==']');
}


vector<pair<int, char>> st;
int p=-1;
int f(int v, int pr)
{
	int res=0;
	int pr_p=p;

	if(is_open(s[v]))
	{
		st.pb({p, s[v]});
		p = sz(st)-1;
	}
	else
	{
		if(st.empty() || !match(st[p].y, s[v]))
			return 0;
		else
		{
			st.pb({p,s[v]});
			p = st[p].x;
		}
		if(p==-1)++res;
	}
	for(auto to: adj[v])
	{
		if(to!=pr)
		{
			res += f(to, v);
		}
	}
	st.pop_back();
	p=pr_p;
	return res;
}

int solve()
{
	int n;
	if(!(cin>>n))return 1;
	cin>>s;
	adj=vector<vector<int>>(n);
	FOR(_,0,n-1)
	{
		int a, b;
		cin>>a>>b;
		--a,--b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	ll res=0;
	FOR(root,0,n)
	{
		p=-1;
		res += f(root,-1);
	}
	cout<<res<<'\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
        cout << "__________________________" << endl;
#endif
    }
#ifdef ONPC
    cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
#endif
}

详细

Test #1:

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

input:

4
()()
1 2
2 3
3 4

output:

4

result:

ok single line: '4'

Test #2:

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

input:

4
[[]]
1 2
2 3
3 4

output:

2

result:

ok single line: '2'

Test #3:

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

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: 1ms
memory: 3612kb

input:

2
()
1 2

output:

1

result:

ok single line: '1'

Test #5:

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

input:

2
)(
1 2

output:

1

result:

ok single line: '1'

Test #6:

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

input:

2
[]
1 2

output:

1

result:

ok single line: '1'

Test #7:

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

input:

2
][
1 2

output:

1

result:

ok single line: '1'

Test #8:

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

input:

2
{}
1 2

output:

1

result:

ok single line: '1'

Test #9:

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

input:

2
}{
1 2

output:

1

result:

ok single line: '1'

Test #10:

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

input:

3
())
1 2
1 3

output:

2

result:

ok single line: '2'

Test #11:

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

input:

3
)((
1 2
1 3

output:

2

result:

ok single line: '2'

Test #12:

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

input:

3
[]]
1 2
1 3

output:

2

result:

ok single line: '2'

Test #13:

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

input:

3
][[
1 2
1 3

output:

2

result:

ok single line: '2'

Test #14:

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

input:

3
{}}
1 2
1 3

output:

2

result:

ok single line: '2'

Test #15:

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

input:

3
}{{
1 2
1 3

output:

2

result:

ok single line: '2'

Test #16:

score: 0
Accepted
time: 155ms
memory: 4384kb

input:

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

output:

2499

result:

ok single line: '2499'

Test #17:

score: 0
Accepted
time: 154ms
memory: 4388kb

input:

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

output:

2499

result:

ok single line: '2499'

Test #18:

score: 0
Accepted
time: 154ms
memory: 4452kb

input:

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

output:

2499

result:

ok single line: '2499'

Test #19:

score: 0
Accepted
time: 210ms
memory: 4312kb

input:

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

output:

6247500

result:

ok single line: '6247500'

Test #20:

score: 0
Accepted
time: 211ms
memory: 4452kb

input:

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

output:

6247500

result:

ok single line: '6247500'

Test #21:

score: 0
Accepted
time: 211ms
memory: 4320kb

input:

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

output:

6247500

result:

ok single line: '6247500'

Test #22:

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

input:

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

output:

1698

result:

ok single line: '1698'

Test #23:

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

input:

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

output:

1768

result:

ok single line: '1768'

Test #24:

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

input:

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

output:

1779

result:

ok single line: '1779'

Test #25:

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

input:

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

output:

993

result:

ok single line: '993'

Test #26:

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

input:

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

output:

6194370

result:

ok single line: '6194370'

Test #27:

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

input:

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

output:

6194370

result:

ok single line: '6194370'

Test #28:

score: 0
Accepted
time: 119ms
memory: 3824kb

input:

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

output:

6194370

result:

ok single line: '6194370'

Test #29:

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

input:

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

output:

6320

result:

ok single line: '6320'

Test #30:

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

input:

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

output:

6320

result:

ok single line: '6320'

Test #31:

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

input:

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

output:

6320

result:

ok single line: '6320'

Test #32:

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

input:

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

output:

2973

result:

ok single line: '2973'

Test #33:

score: 0
Accepted
time: 4ms
memory: 3832kb

input:

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

output:

3382

result:

ok single line: '3382'

Test #34:

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

input:

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

output:

3066

result:

ok single line: '3066'

Test #35:

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

input:

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

output:

1207

result:

ok single line: '1207'

Test #36:

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

input:

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

output:

4998

result:

ok single line: '4998'

Test #37:

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

input:

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

output:

4998

result:

ok single line: '4998'

Test #38:

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

input:

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

output:

4998

result:

ok single line: '4998'

Test #39:

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

input:

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

output:

4998

result:

ok single line: '4998'

Test #40:

score: 0
Accepted
time: 1ms
memory: 3988kb

input:

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

output:

4998

result:

ok single line: '4998'

Test #41:

score: 0
Accepted
time: 1ms
memory: 3856kb

input:

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

output:

4998

result:

ok single line: '4998'

Test #42:

score: 0
Accepted
time: 85ms
memory: 3976kb

input:

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

output:

1239

result:

ok single line: '1239'

Test #43:

score: 0
Accepted
time: 35ms
memory: 3988kb

input:

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

output:

1230

result:

ok single line: '1230'

Test #44:

score: 0
Accepted
time: 48ms
memory: 3852kb

input:

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

output:

1272

result:

ok single line: '1272'

Test #45:

score: 0
Accepted
time: 82ms
memory: 3856kb

input:

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

output:

842

result:

ok single line: '842'

Test #46:

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

input:

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

output:

6242503

result:

ok single line: '6242503'

Test #47:

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

input:

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

output:

6242503

result:

ok single line: '6242503'

Test #48:

score: 0
Accepted
time: 108ms
memory: 3988kb

input:

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

output:

6242503

result:

ok single line: '6242503'

Test #49:

score: 0
Accepted
time: 108ms
memory: 3928kb

input:

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

output:

6242503

result:

ok single line: '6242503'

Test #50:

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

input:

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

output:

6242503

result:

ok single line: '6242503'

Test #51:

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

input:

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

output:

6242503

result:

ok single line: '6242503'

Test #52:

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

input:

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

output:

6247500

result:

ok single line: '6247500'

Test #53:

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

input:

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

output:

6247500

result:

ok single line: '6247500'

Test #54:

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

input:

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

output:

6247500

result:

ok single line: '6247500'

Test #55:

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

input:

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

output:

6247500

result:

ok single line: '6247500'

Test #56:

score: 0
Accepted
time: 109ms
memory: 3872kb

input:

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

output:

6247500

result:

ok single line: '6247500'

Test #57:

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

input:

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

output:

6247500

result:

ok single line: '6247500'

Test #58:

score: 0
Accepted
time: 18ms
memory: 4004kb

input:

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

output:

1209

result:

ok single line: '1209'

Test #59:

score: 0
Accepted
time: 76ms
memory: 3984kb

input:

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

output:

1175282

result:

ok single line: '1175282'

Test #60:

score: 0
Accepted
time: 23ms
memory: 3960kb

input:

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

output:

1220

result:

ok single line: '1220'

Test #61:

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

input:

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

output:

183371

result:

ok single line: '183371'

Test #62:

score: 0
Accepted
time: 150ms
memory: 4448kb

input:

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

output:

2500

result:

ok single line: '2500'

Test #63:

score: 0
Accepted
time: 155ms
memory: 4380kb

input:

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

output:

2500

result:

ok single line: '2500'

Test #64:

score: 0
Accepted
time: 155ms
memory: 4324kb

input:

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

output:

2500

result:

ok single line: '2500'

Test #65:

score: 0
Accepted
time: 210ms
memory: 4512kb

input:

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

output:

6250000

result:

ok single line: '6250000'

Test #66:

score: 0
Accepted
time: 212ms
memory: 4328kb

input:

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

output:

6250000

result:

ok single line: '6250000'

Test #67:

score: 0
Accepted
time: 211ms
memory: 4376kb

input:

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

output:

6250000

result:

ok single line: '6250000'

Test #68:

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

input:

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

output:

1763

result:

ok single line: '1763'

Test #69:

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

input:

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

output:

1718

result:

ok single line: '1718'

Test #70:

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

input:

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

output:

1829

result:

ok single line: '1829'

Test #71:

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

input:

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

output:

1031

result:

ok single line: '1031'

Test #72:

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

input:

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

output:

6197100

result:

ok single line: '6197100'

Test #73:

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

input:

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

output:

6197100

result:

ok single line: '6197100'

Test #74:

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

input:

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

output:

6197100

result:

ok single line: '6197100'

Test #75:

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

input:

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

output:

6320

result:

ok single line: '6320'

Test #76:

score: 0
Accepted
time: 192ms
memory: 3976kb

input:

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

output:

6320

result:

ok single line: '6320'

Test #77:

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

input:

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

output:

6320

result:

ok single line: '6320'

Test #78:

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

input:

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

output:

3919

result:

ok single line: '3919'

Test #79:

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

input:

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

output:

3419

result:

ok single line: '3419'

Test #80:

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

input:

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

output:

3334

result:

ok single line: '3334'

Test #81:

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

input:

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

output:

1336

result:

ok single line: '1336'

Test #82:

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

input:

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

output:

4999

result:

ok single line: '4999'

Test #83:

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

input:

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

output:

4999

result:

ok single line: '4999'

Test #84:

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

input:

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

output:

4999

result:

ok single line: '4999'

Test #85:

score: 0
Accepted
time: 1ms
memory: 3984kb

input:

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

output:

4999

result:

ok single line: '4999'

Test #86:

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

input:

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

output:

4999

result:

ok single line: '4999'

Test #87:

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

input:

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

output:

4999

result:

ok single line: '4999'

Test #88:

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

input:

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

output:

1246

result:

ok single line: '1246'

Test #89:

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

input:

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

output:

1207

result:

ok single line: '1207'

Test #90:

score: 0
Accepted
time: 45ms
memory: 3852kb

input:

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

output:

1230

result:

ok single line: '1230'

Test #91:

score: 0
Accepted
time: 82ms
memory: 3924kb

input:

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

output:

890

result:

ok single line: '890'

Test #92:

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

input:

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

output:

6245002

result:

ok single line: '6245002'

Test #93:

score: 0
Accepted
time: 108ms
memory: 3960kb

input:

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

output:

6245002

result:

ok single line: '6245002'

Test #94:

score: 0
Accepted
time: 110ms
memory: 3992kb

input:

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

output:

6245002

result:

ok single line: '6245002'

Test #95:

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

input:

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

output:

6245002

result:

ok single line: '6245002'

Test #96:

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

input:

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

output:

6245002

result:

ok single line: '6245002'

Test #97:

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

input:

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

output:

6245002

result:

ok single line: '6245002'

Test #98:

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

input:

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

output:

6250000

result:

ok single line: '6250000'

Test #99:

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

input:

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

output:

6250000

result:

ok single line: '6250000'

Test #100:

score: 0
Accepted
time: 108ms
memory: 3984kb

input:

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

output:

6250000

result:

ok single line: '6250000'

Test #101:

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

input:

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

output:

6250000

result:

ok single line: '6250000'

Test #102:

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

input:

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

output:

6250000

result:

ok single line: '6250000'

Test #103:

score: 0
Accepted
time: 108ms
memory: 3992kb

input:

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

output:

6250000

result:

ok single line: '6250000'

Test #104:

score: 0
Accepted
time: 77ms
memory: 3928kb

input:

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

output:

1181521

result:

ok single line: '1181521'

Test #105:

score: 0
Accepted
time: 37ms
memory: 3928kb

input:

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

output:

402169

result:

ok single line: '402169'

Test #106:

score: 0
Accepted
time: 78ms
memory: 3932kb

input:

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

output:

1162482

result:

ok single line: '1162482'

Test #107:

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

input:

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

output:

823

result:

ok single line: '823'