QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#464162#126. Balanced StringspropaneAC ✓251ms22912kbC++202.7kb2024-07-05 21:07:332024-07-05 21:07:34

Judging History

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

  • [2024-07-05 21:07:34]
  • 评测
  • 测评结果:AC
  • 用时:251ms
  • 内存:22912kb
  • [2024-07-05 21:07:33]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<vector>
#include<array>
#include<map>
using namespace std;
using LL = long long;
const int maxn = 1e5 + 5;
vector<int> g[maxn];
int a[maxn];
bool v[maxn];

int get_wc(int u, int fa, int tot, int &wc){
    if (v[u]) return 0;
    int mx = 0, sum = 1;
    for(auto j : g[u]){
        if (j == fa) continue;
        int t = get_wc(j, u, tot, wc);
        mx = max(mx, t);
        sum += t;
    }
    mx = max(mx, tot - sum);
    if (mx * 2 <= tot){
        wc = u;
    }
    return sum;
}

int get_sz(int u, int fa){
    if (v[u]) return 0;
    int ans = 1;
    for(auto j : g[u]){
        if (j == fa) continue;
        ans += get_sz(j, u);
    }
    return ans;
}

void dfs(int u, int fa, int sum, int mn, int mx, vector<array<int, 3> > &p){
    if (v[u]) return;
    sum += a[u];
    mn = min(mn, sum);
    mx = max(mx, sum);
    p.push_back({sum, mn, mx});
    for(auto j : g[u]){
        if (j == fa or v[j]) continue;
        dfs(j, u, sum, mn, mx, p);
    }
}

LL ans;

void calc(int u){
    if (v[u]) return;
    get_wc(u, -1, get_sz(u, -1), u);
    v[u] = true;

    map<int, int> mp1;
    vector<map<int, int> > mp2(g[u].size());
    vector<vector<array<int, 3> > > p(g[u].size());
    for(int i = 0; i < g[u].size(); i++){
        int j = g[u][i];
        dfs(j, -1, 0, 0, 0, p[i]);
        for(auto [sum, mn, mx] : p[i]){
            if (sum + a[u] == 0){
                if (min(mn + a[u], a[u]) >= 0) ans += 1;
                if (min(sum - mx, sum + a[u]) >= 0) ans += 1;
            }
            int need = 0 - (sum + a[u]);
            if (need >= 0 and need + a[u] >= 0 and need + a[u] + mn >= 0){
                mp1[sum] += 1;
                mp2[i][sum] += 1;
            }
        }
    }
    for(int i = 0; i < g[u].size(); i++){
        for(auto [sum, mn, mx] : p[i]){
            if (min(sum - mx, sum + a[u]) < 0) continue;
            int need = 0 - (sum + a[u]);
            if (mp1.contains(need)) ans += mp1[need];
            if (mp2[i].contains(need)) ans -= mp2[i][need];
        }
    }

    for(auto j : g[u]){
        calc(j);
    }
}

int main(){

#ifdef LOCAL
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
#endif

    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);

    int n;
    cin >> n;
    string str;
    cin >> str;
    for(int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i = 0; i < n; i++){
        a[i + 1] = (str[i] == '(' ? 1 : -1);
    }
    calc(1);
    cout << ans << '\n';

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 36ms
memory: 6504kb

input:

37589
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))...

output:

0

result:

ok single line: '0'

Test #2:

score: 0
Accepted
time: 44ms
memory: 7592kb

input:

50247
))))))))))())))))))))))))))))))))))))))()))))))))))())()))))))))))))))))))))()))))))))))()))))))())))))))))))()))))))))))))))()))())))))))))))))))))))))(())))))(()))))()())))))))())))())()))))))))))))))))))))))))))))))())))))))))))))))())())))))())))()))))()))))))))))))()))()))))))))))()))))))...

output:

23079

result:

ok single line: '23079'

Test #3:

score: 0
Accepted
time: 60ms
memory: 8296kb

input:

56977
)))))))))()))()()))())))))()))))))))()())))()))))(())())())())))))())()))())()))))))())))))))))()()())))))())))))()))))())(()())))))))))))))))))))))))))())())))))))()(()()))))))))()())))())))))))))((()(()))))))))))))))))))()))))))))()(()))))))))))(())))))))))())))))))))))())))))))))(())))))())...

output:

994794

result:

ok single line: '994794'

Test #4:

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

input:

98567
)))()))()()))))))))))))))))))()))()()((((()))))())(())))()))((()(()))))())))()())))))())((()))((())())())))(())()()(()()()))(())))))()(())()()()(()))))())))))())(()))((((())()))()())))))))))())))))(())(()))()()()))()))))))))))()))))((())(()))())))(()()()()()))((()))()())))))))()()())((()))))))...

output:

15650664

result:

ok single line: '15650664'

Test #5:

score: 0
Accepted
time: 28ms
memory: 5884kb

input:

27916
())(()))))))()))((()((())()))()))())))(())(())(()))(()()))))())))(((()))))()()()))))()()((()())()())))()))))))))(())()))))()())()())(((()((()((()(((()(())()()))))))()))))))())((()))()((()()())(((((((()(()()))(())))(()())(()(())))()(()))())))))((((()()()()))()()(()()())()()(()())((())(())(())))...

output:

5339607

result:

ok single line: '5339607'

Test #6:

score: 0
Accepted
time: 68ms
memory: 8976kb

input:

69001
()(()))))()()())))()(()))))()))(())())((()))))((()(()()))()())()))()(()))((()))))(())(()(()()()()()()(()(())))(()())))()(())()())())((((()))()))((())())(())()(((()((()((())((()())))(((()()()))()))(((()())(((()(((())()((((((()))(()())))))((())(()(())))(()()()(()()()))()(()(()())(()()(((((((()()...

output:

49390858

result:

ok single line: '49390858'

Test #7:

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

input:

21304
((())(((())((((()))(((()))((((((()((((()(((()()()((()((((()(((((((((((()(()))(()()()()))((((((((((((())((((((((((()(((((()(())))((((((()))))()()))()())(()))))(((((()()(())((()(((((((()(((()()()())((((()(((()())(()((((())(((()(((((((((((()))())(())()())()(((((((()()()((()(()()))(())((((((())()(...

output:

2884692

result:

ok single line: '2884692'

Test #8:

score: 0
Accepted
time: 38ms
memory: 7336kb

input:

45253
())((((()()(())((((())()(((())))))()(((()((((()((())(((()))))((()(((((((((((()((((((()(()()((()()()()(()))((((((((((((((())((()(((((()()()((((((((((((((((()((()((((((((()))(()())(((((((()(()())()))((((()))((())()(()()))((((()((())()(()(((()(((()((())()()(())()(()((((((()((()(()()()((())(()))((...

output:

8601971

result:

ok single line: '8601971'

Test #9:

score: 0
Accepted
time: 30ms
memory: 6188kb

input:

32819
()(((((((((()((()((((((())((((((((((((()((()((((()((()(((((((()(((((()(((((((((()(((((()(()((((((((((((((())(((((((())()(()(((((()((((((()(((((((((((((((((((((((((()(((((()))((()((((()(((()(()(((()())(((()(((()(((())()(((((((((((((((((((((())(())()(()(())()((()(()(((((((((())((((()(((((()()(((...

output:

192545

result:

ok single line: '192545'

Test #10:

score: 0
Accepted
time: 81ms
memory: 10596kb

input:

93339
(((((((((((((((()(((((()()()(((((()(((((((((()((((((((()(()(((((((((((((((((((((((((()(((((((())()((((((((((()((((((((((((((((((((((((()((((((((((((((((()((((((((((()(((()(((((((()(((((()(((((()(((((((((((((((((()((((((()(((()((((((()()((((((((((((((((((()((((((()((((()(())(((()((((((()(((((((...

output:

53225

result:

ok single line: '53225'

Test #11:

score: 0
Accepted
time: 50ms
memory: 8220kb

input:

59383
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((...

output:

0

result:

ok single line: '0'

Test #12:

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

input:

100000
())))()()))()((()(()()((())())((()))(()))()()(()()(())()((())())())))(()))())()))())))))((((()()(()()()()()())))))))((()))(((()())()()()(((((())(((()(())(()(())((())))()()()((())))()((((((()))()(((())())((()(())))(((()((()())(()(()((((()()((())()((()())(()(()))(())(()(()((((()((()())()(()()((...

output:

86558204

result:

ok single line: '86558204'

Test #13:

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

input:

100000
(())((())(()(()()))()(((())))(())())(()())()))))()((()(((()))((()((()()())))()(())()()()()()(()((()(())()))((()())(((())(()(((())()()(()))(())())())(()()()))))()(()))()()((()(((()())())())))))(((())))()((())()(()()()()()())())(()())())))(()())))()()(()()()((())))((())))))(()()))((())))())((((...

output:

85291914

result:

ok single line: '85291914'

Test #14:

score: 0
Accepted
time: 121ms
memory: 11716kb

input:

100000
))(()()))))())()())(()()))))(()))()()(()((()()((((()))(((())())())()))())()()()))))(((()(()())((((((()))))))()())((()()))((((())()())()()()()))(()((((()()))()(()))(()()))())())(())()(()((()(()(()))(((()))))))()()()())()))()())())()))(()(()())()()(()))(((((())()()())))())())(())((()(()))()))()...

output:

81274356

result:

ok single line: '81274356'

Test #15:

score: 0
Accepted
time: 116ms
memory: 12060kb

input:

100000
((()()(((()(()))((((()()(()(((()())(()())((()(()))()(()(()()))))(()(()()((()((()())()(((()(())()()()()((((()(()))()))))))))()())))(()((((()((())))()(()))))(())(()()(()())))()())))(()())(((((()))())((((()((()))()((())())()(()(()())))()()()())))(((())))(()()((()))(())(()())()())(())()))))()))))...

output:

95427650

result:

ok single line: '95427650'

Test #16:

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

input:

100000
))()))))(()())))()()()()(())(((()()())))(((((())()()(()))()()()(((((((()())()()()(()((()))(()((())((()())((()(())))((()()()())(())(())())))()())()())()))(()()))()((()()()())))()))(()((((((()(()(((()((()))(()((()))(()((()())()))((((()())()))))))))()())))((()))()()()))(()((()(()(()()())())))())...

output:

84225313

result:

ok single line: '84225313'

Test #17:

score: 0
Accepted
time: 231ms
memory: 22752kb

input:

67928
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))...

output:

0

result:

ok single line: '0'

Test #18:

score: 0
Accepted
time: 251ms
memory: 22376kb

input:

74375
))))))()()))))())(((())))))))((()))())))))())))()))))))))))))))))))))))))(()))()()))))))()))))))))))))))))))))))())))())))))))))))()))))))))))))))))))))))))))))))))))))()))))))))))))()())))))))))))))))())(())()))))()))))))))))))))))))))))))))))))))())(())))))())))))))))))))))))))))))))))))))))...

output:

16424

result:

ok single line: '16424'

Test #19:

score: 0
Accepted
time: 122ms
memory: 14080kb

input:

43700
))()))))))()))))()))))))))))())))))))))))))))))))())())()))))())))())())())))())()))))))))))()))))))())))))()))()))())))))))()())()))((()))))()))))))))((())()))))))()))((())))))(())))))))()()())((((()())))))()))))(())))))(())(()))))()()())))))()))))()))))))))))))()))))))))))()))((())((()))))()...

output:

21924

result:

ok single line: '21924'

Test #20:

score: 0
Accepted
time: 145ms
memory: 14532kb

input:

55191
))()))())())))))()))())(())())((())())))))())))))()))))())))))()))(())))))))(())))(())))))()(()))((()))((()))))()))()))((())()))())))))())())))()))))))())))))()))()()((())())()))))))))))))))())))(()))())))())())))()))))()))))()))))())()((()))))))()))()))))))())))()))())())())()()))))()))()))()...

output:

47224

result:

ok single line: '47224'

Test #21:

score: 0
Accepted
time: 56ms
memory: 8796kb

input:

28230
())((()))))())))())))()())(())()))()(()()(()))))))((()()))))))(())())(()(())))())()))))))))))))()()())()()()((()(())())())(()())))))))()))))())()()(()))())))()(()()))))()(())))))((((((())()()((()(()())))())())))()()((()()()))(()(()(()))())()()))))))())())())())))(((((())))((((((())()()))(()()(...

output:

37491

result:

ok single line: '37491'

Test #22:

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

input:

99972
)((()))(((((()((()((())((())((()()))()()()()))(()))))(())())())))())))))()((((((()))))))())))(()((())))(((()))((()()((())())(()())(()()(()()()((())(()()))()))))))()(()()()))(()(())((())((()((((()()(())))())()(((())()())()((())))))(())))))))()()())()(()(((((())))()))())())())()((()))((()(()(())...

output:

199386

result:

ok single line: '199386'

Test #23:

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

input:

60778
()()((((((((((((()))))(())(((((())()(((((()((())(()()())))())()))()(()(((()())))((())))))()(()()((((()(()())()((())(()(((()())()()(()(((((((()()()(((()((()(((()))()(()))))(()()(()(((()())))(((((((()()(((((((()(((((((()((()()()()())(()(()()()((((())((())))))((((()((((()(())(())()))()(((())(((()...

output:

81154

result:

ok single line: '81154'

Test #24:

score: 0
Accepted
time: 203ms
memory: 17344kb

input:

98456
()((((()((()(()(()(())(((()()))(((()(()()(((((()()((())((()((((((()()((((()((((()()(()(((((()(((((()(()((()))(()())((((())()(()()(((()(()(()()())()((((()(()))((())((()(()(((((((()(())(((((((((((((((())()((((()(((())()(((()()((((((((())(((((()()(()((()))(((()(())((()(((())(((((((()))()())((()((...

output:

84235

result:

ok single line: '84235'

Test #25:

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

input:

19318
)(((())()))())(()()((((((()(((()(()((()(())((((((()()))(((((((()(((((()((((()((((()(()(((((((((((((((((((((((()(()((((((((((((())(((((()()(((()((((((((()((())(()((((())(((((()((()()((()()(((((((((((((((((((((()((((((())(((((((()(((()((()((()(()((()(((((((((((()(()((()(((((()((((((())(((((()(((...

output:

9687

result:

ok single line: '9687'

Test #26:

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

input:

114
(((()((((((((((((((((()(((((()((((((((((((()((()(((((()((((((((((((((((((()((((((((((((()(((((((((()()(()(((((((()
19 14
20 58
38 90
113 11
57 98
92 57
52 7
53 33
112 84
83 34
82 100
60 35
61 75
103 38
45 36
69 66
5 59
12 53
2 32
28 112
30 93
88 78
108 61
91 43
84 111
86 83
79 29
76 110
24 37
35...

output:

28

result:

ok single line: '28'

Test #27:

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

input:

51196
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((...

output:

0

result:

ok single line: '0'

Test #28:

score: 0
Accepted
time: 222ms
memory: 17476kb

input:

100000
()()((())())((())(())()()()()((()))()((()())))(()(()()))))(((())(((()(()()))))((((()((((()()(()()(())))))))(())()((((()(())(()))))())())(()(())()))(()()(()))((((((()))((()((())(())))(()))()()((((())()))))))())))))(())()()))()()()(()))))()(((())))))((()))())(()(()(((()()(()()())(()((((((()())(...

output:

198658

result:

ok single line: '198658'

Test #29:

score: 0
Accepted
time: 221ms
memory: 17568kb

input:

100000
)))()(()))(((((())))((())()()(()((()))((()(((())((()(((()(((()())((())()()((())))(())))(()()))()((((())(())())()()))())())))))())()(()(()(()())(()(()())()()()())))(()()((())()))(()())(((()))))())()(())))))())((())()))()()))()))((()()))))())(((()(()())()()))(()))())(())(()(()))))))()))))(()()(...

output:

198838

result:

ok single line: '198838'

Test #30:

score: 0
Accepted
time: 219ms
memory: 19284kb

input:

100000
)()()()()())))))()((((()())(())()(()))(()(()()((())((()()))(()(((())))())((((((()()()))))))())))()())))()((((()(((()))()(((())()))((((((())((())())))()(())))(()()()())()(()(((())(((())(()()))(((((((((()((()())()()((((())((()())()))())))()()(((())))))()(())()))(())))))(()()(()))(()))))))))()))...

output:

199464

result:

ok single line: '199464'

Test #31:

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

input:

100000
)()()((()(()(((()(()()()())(()()())(()())(()()((())(()()))()()()(()((((())))))()())(()(((())()(()(()(()())))))))(()()))())(())())()))())(())((((((()(())()((())())())))())(((()()()()()))))(()))()())))((((()(()(((()))((()(()()(()()()()(()(()()(()())))()))()))()))())(()()()((()()()()()(((()(())(...

output:

197737

result:

ok single line: '197737'

Test #32:

score: 0
Accepted
time: 218ms
memory: 18668kb

input:

100000
)))()()()))())(())(()((((()))))()((((()))()()()(())()))((()(())))((()((()())((())()()()(())())))((()))))(())()()))((()(((((())(()())((()()((()))()()()(((()()))(()(()())))))(((())((((()())((()())))))())())()))((())(((()))(())(((()(())()()()()(((()()(()))))()))))()(((()))))))((())(()))())))))((...

output:

197044

result:

ok single line: '197044'

Test #33:

score: 0
Accepted
time: 27ms
memory: 22912kb

input:

93277
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))...

output:

0

result:

ok single line: '0'

Test #34:

score: 0
Accepted
time: 20ms
memory: 17360kb

input:

67885
)())))))))))))))))))))))))))))())())))))))))))))))))()))))))()))))))))())))))))))))))))))))))))))()))()())))))))))))))))))))))))())))))))))))))))))))))))))))))))))))))())))))))))())()))))))))(())))))())()(()))))))))))))()))())))))))))))))))))())))))))))()())))))))))))())))))()))))))))())))))()...

output:

6788

result:

ok single line: '6788'

Test #35:

score: 0
Accepted
time: 14ms
memory: 17012kb

input:

67814
))))())))))))))())))((())))))))))()(()))))))))))()))())))(()())))))()))))()))))((())())))))))(())))()()))()(()()))))()))()))(()))())))))))(()()))))()))))())())))))()))))))))))())))))))(()))))))())))(()))))))())))))()))))))))))))())))())))))))))()))(())))()())))()))))()))))))))())())())(())))))...

output:

13562

result:

ok single line: '13562'

Test #36:

score: 0
Accepted
time: 15ms
memory: 14692kb

input:

57612
))()()))))()))())))))))))()))((()))))())())())))))))()))()()()))()))))(())))()))())()()((())())))(()()())))()()))))))(()()()()(())()())()(()))))))))())()))(()))(())()(()))))))()))))))()())()()(()))))(()))))(())(()))))(()())(())))(())))))))))(((())()()()))(()(()()))))))))))))()()))()()))((())))...

output:

17283

result:

ok single line: '17283'

Test #37:

score: 0
Accepted
time: 6ms
memory: 12412kb

input:

47785
))))(()((()(((((((((())())()())))))))())))()))))())))())))))))((()))((())())))))())))))))((()))()((())))())())))))))))(()(()((()))(((()((()))()())((())(()()))(()()()()())))()(())()()())))()()(()))()))())((())()()(((()))((()))((()))((((()(((()))(())(()()(((((())((()))())))))(()()()())))()))())(...

output:

28671

result:

ok single line: '28671'

Test #38:

score: 0
Accepted
time: 14ms
memory: 12856kb

input:

50600
)(((())))()((((()(()(())((()())(()())(()()())))()((()()()))((()()))))()))())))))(()()(((()))()())((((())(()(()))(()(()((())()((())()))(()(((()))))((())))(((()()(((((((()()))))))(()((((((((((())((()()()))))()))(()))())(()(((()((()(())()())())()))))()))()()())))()((((()(()))())(()())()()()()(()(...

output:

25300

result:

ok single line: '25300'

Test #39:

score: 0
Accepted
time: 6ms
memory: 6084kb

input:

16000
(()(()()(()()((()())()()(())(((()()(()((())()((()(((()(((()(()())(((())(((()))))(()(((())(())))()()(())()()(()(())((()(()())((()((((()(((())())))(())))))((()(()()((()((()(((()(()()())(()((())()(((())(()))()((((()()))()()()(((())((())()())(((())())())))((((((()()(()()((((()(()()((((()(())()())(...

output:

9600

result:

ok single line: '9600'

Test #40:

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

input:

33322
(())(((((((()(()(()(()())(()()()((()))())()(())((()())()((()((()()))((((()((()(()(((()(((((((((((((()((()(()()()(()))((((()((((((())(()(((()((((((((((((((()()()(((((((((((((((()(((((((()(((((((((()(((((()()()(((()(((()(()((())(((()((((((((((((()))(((()(((((()))(())(()()((()()())()((((((()(((((...

output:

9997

result:

ok single line: '9997'

Test #41:

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

input:

11048
((()))(((((((((((((((((((((((()((((((()(())((()(()(((()(((((()()))()((((((()(()((((()())((((((((((((()()((((()(((((((((()((((((((()((()(((()(((((()((((((()()(((((()())(((((((((((((())((((((((((((()(((()(((((((()))((((((((((((((((((()((((())((((((((((())(((()(()((()((()(())(()((()((((((((((((()...

output:

2210

result:

ok single line: '2210'

Test #42:

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

input:

82724
(()((((((((((((((((((((((((((((((((((((()()(()(()()((((((()(()(((((((((()((((((()))((()(((((()((((((((()(()(((((((()(((((((()(((((((((()((()(((()((()((((((((((((((((((((((((((((((((((((((((((((((((((((()((((((((((()(()((((((((((((((((()(((((()((((((()(((((()((()((((((((((((((((((((((((((((((((...

output:

8273

result:

ok single line: '8273'

Test #43:

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

input:

39744
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((...

output:

0

result:

ok single line: '0'

Test #44:

score: 0
Accepted
time: 24ms
memory: 22244kb

input:

100000
()((()()))((()()(((()))()(()(((()()(())())(()(())()(()))))))(()())()()()(())(()()))))()(())((())()((((())(()())()())(())())))((())()()))(()())))))(())()()(()((()()())))())))()())()()())))(((()(((()()))))))((()(()())())))))(()(()))(()()()((()()()((())))((()())()(()(()())(((((())(()(()())(()(((...

output:

50046

result:

ok single line: '50046'

Test #45:

score: 0
Accepted
time: 28ms
memory: 22060kb

input:

100000
))(((()))((()()()()))))))()((())())()))())(()(()))()()(((()))))()(((()()))(()()())))((()())((((((((()(()())()))()(())(()))()(()()())()(()((()(()())())))())((()()))))))((((()(()())()(())((()()()()((()))())()(())(())(())(()((()()))(()((())((())))())(()))))((()))())()()()()))()()(()()()()))))())...

output:

49914

result:

ok single line: '49914'

Test #46:

score: 0
Accepted
time: 26ms
memory: 22128kb

input:

100000
))(()))(((((())())()()((()())))))(())(()))((())((())()))(()(()())(()))))()))()()))((()())())())()((((()))(()()((())()))())))()(((())())())))(()))()()))((()(()(())()))))(()()(())()(((()((())))(((())))))()(()()(())())(()())()))())(((()(((()((((((())))((())))))(()((())))((((())))))((()()()())))(...

output:

50031

result:

ok single line: '50031'

Test #47:

score: 0
Accepted
time: 30ms
memory: 22236kb

input:

100000
)()()))(()))(()()(()()(((((((()((()))()))((()(()())()(())(((()(()()(())))())()))(((())(((((((((((((()))(()()))))(()(((((()()(()))())((())())())(()((())()(()((((())((()(((((()))))((())(())(()(()()(())())((()()(()))((()))))))))((((())()))())(((())()()(((()(())())())))((())))))()))()))((()))(())...

output:

49844

result:

ok single line: '49844'

Test #48:

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

input:

100000
)))()))(()))()))((()((())(()()))))(()(())))))()((()(()(()(()(())(((()((((())(((()(((())())(()(())(()((()()(())())(())(()(())(((())()())())())))))()(())()(()((())()(())()))(((()())()((()()))((()())))())()()(()())))())()()())((((())()())(()()))())())())(())()((()((()))()))()(())()))(()))))()(()...

output:

49986

result:

ok single line: '49986'

Test #49:

score: 0
Accepted
time: 56ms
memory: 8212kb

input:

57169
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))...

output:

0

result:

ok single line: '0'

Test #50:

score: 0
Accepted
time: 13ms
memory: 5028kb

input:

16876
())))))))())))))))))))))))))))))))))())))))))()))))))))))))()))))))))())))))))))()))))))))))))))))))))))))))))))))))))))))))))))))))())))))))))))())))()))))))))))))))))))))))()))))))))))))))())))()))))(())))))))()())())))))))))))))))))))))()))((()))))(())())))))))()))))))())())))))()))))))))))...

output:

5090

result:

ok single line: '5090'

Test #51:

score: 0
Accepted
time: 32ms
memory: 6148kb

input:

29919
())())))())()))))))))))(())())()()())()()))))))))))))))))(()))))))())))()))))))))())())())))))))))))()))))())()(())((())))))(())))))))()()))))))))()))))))())(()))(())))))(()))()))))))))))())()()))))()))))))()()()))())()))())()()))))()))((())()))))())))())))()()))))))(())))(())))())))))(())))))...

output:

68453

result:

ok single line: '68453'

Test #52:

score: 0
Accepted
time: 80ms
memory: 8812kb

input:

66512
)(())))(())())))))))))())))))))())(()()))())()())))()))))())))()))))())()))))(()(()()))(())))))))())))))))))((())))()))))()))()))()))()()))())))))(()))()()()()))))))))())))(()))(()))))(()))))((()))((((()())))(())(()))))())))()((()()()))()))())))))())(())(()())))))))()())))(((())))()))())))(())...

output:

1528331

result:

ok single line: '1528331'

Test #53:

score: 0
Accepted
time: 87ms
memory: 9360kb

input:

72163
()(())))(((()(()))))())))()))(()())))))))())())()()))()))()))()()))(()))(()((())(()((()))()())()))))()()()()((())))()((()))()))))(())()(())))))()()))(()()))()))))))))())())(()(()))))())))())()))()()))((()()))))())())(((()(()))(((((()))))()))(()()))(())((()(((()))(()))()))))))))()())()(()()))))...

output:

17130357

result:

ok single line: '17130357'

Test #54:

score: 0
Accepted
time: 39ms
memory: 6156kb

input:

34189
())()))))(((()()(((())()()())())((()())()()()))((()))()))(())((((()(())))())())))())(())((()))((()))(((())(()))(()))(()))((())))))(()(()((((((()()(()((()(((((()((())()(((()(((())(((())((()))))(())((((((())(((((((())()))))))()(())())()(())(()(()()))()()))())())()((())((((()))()))()))()()((()(((...

output:

6079783

result:

ok single line: '6079783'

Test #55:

score: 0
Accepted
time: 95ms
memory: 10184kb

input:

87137
((())))((((((()(((())(()()))(((()())(((((()(())((())(((()()))((((((())())())(())(())))()((()((((()()((()())()))()(()())))(()()(((()())))((((())))()))(()())())(()(()(()(()())(((()()()(((()(()())()()()(()(())))((((()(()((()(()(((()((((()))))))((())(()(())())))(((()((()()(())())()(()(((((())()(()...

output:

30343042

result:

ok single line: '30343042'

Test #56:

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

input:

96188
()(()((())()()((((((()))(()()()((()((((((((((()(((((()(((()())(()(()(()((((()()(((()(((())))((()()()(())))(((((((((()(()((()(((((((((()(()(()((((()))()(()))()(((())(()((((((()))))((((()(()(()(((((()()()))(((((((((((()(((()(((()()))(((((()(()(())(((((())(((()(((((()(((((())((((((((())(()))(((((...

output:

1769546

result:

ok single line: '1769546'

Test #57:

score: 0
Accepted
time: 24ms
memory: 5900kb

input:

30179
(((((((())((((()(()))((()(((()(()))(()(()()((((((((())((((((((((((()(((())()(((((((((((()((((((((((((()(((((((((((()()((((()(((())(()((()(()(((((()(()(((((((())(()())(((((((((((()(()((((((((((()))()((()((((((((((((((((()())(((((()(()((((((()((((((((())((((((()(((((((((((((((((((((((())(((()(()...

output:

61248

result:

ok single line: '61248'

Test #58:

score: 0
Accepted
time: 53ms
memory: 8004kb

input:

57478
(()((((()()()(()((((((((((((((((((((((()(()((((((((((((((((((((((((((((((((((((((()((()((((((((((((((()((((()(((())()(((())(((((((((((((()((((((((((((()(()((((((((((((((()(((((((((((((((((()((((((((((((()(()((((((((((((((((((((((()((((()((((((((((((((((()(((((((())((((((((((((((((()(((((((((((...

output:

18474

result:

ok single line: '18474'

Test #59:

score: 0
Accepted
time: 59ms
memory: 9128kb

input:

69944
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((...

output:

0

result:

ok single line: '0'

Test #60:

score: 0
Accepted
time: 129ms
memory: 11452kb

input:

100000
)()()())()(()())()(((((()()()))((()()))(()(()()))))(()))()(()()())()))))()))(())))())(()))())()()(()())((())(()((((())(()())()()()()(()((()(((())())(()())))))())))())())()())()()))((()()(((((()()(((())(()(((()())(((((((((()))()))(()()))((()(()())(())))))))((((())()(((()()(()))(()((()(((()()))...

output:

38330131

result:

ok single line: '38330131'

Test #61:

score: 0
Accepted
time: 125ms
memory: 11468kb

input:

100000
)(()(()(())((())(((((())()()))))())())()((())()()))(()))))))(()(((()())()()(()()))))())(()()))()((((())((())))()()()))((())))))(()((()))))))())))()(())(()((()))()))()((()())))())(()())())(()())())())))(()))(()()()(()(()))()()(((())()((()((())))))(())(()())((((())))()((()(())(((()()()()(()()))...

output:

54603714

result:

ok single line: '54603714'

Test #62:

score: 0
Accepted
time: 133ms
memory: 11520kb

input:

100000
(())()))(())()()))(((())))(()(()))(()())()()))))()(()(()()(()((()()()()((()))(((((((())()((()(()(()))))(((()(((((()(((()))())(()(((())(())((()))()(()))()(()()))((((()()((((()))))()))))((()))))(()(()(()(())(((())(((()()))())()(()()((()(())()))((()()()()))()()(()(())()((()())((((((())())))(()((...

output:

41579487

result:

ok single line: '41579487'

Test #63:

score: 0
Accepted
time: 120ms
memory: 11460kb

input:

100000
)(()((()))()(())(()(())((()(()())(((()(((())))))(()))))()()()))(((((((()(())(())))()))((()())((()()())())))(((((((())((())())(()()))))(()))((())))(())))())((()(()((())(())))()(()()()()((())()))))((()((()((())()(((()))))(()()())(()((((()))(((()()()))(()())()(())(()))))))())((((()((((()((())())...

output:

49681589

result:

ok single line: '49681589'

Test #64:

score: 0
Accepted
time: 124ms
memory: 11388kb

input:

100000
)())))()()(())()((())))())(((())()(()))))()()((()))())))((()))(((((()((()((((()())()())((((()))()()()))))()()())())())))()(()))()()(((())))((())()())(()()(())))())))()))((()()))(()())())()((((()((())(())))(()))((()()())(())()))()(()()))(()())))(()()(((((())()(((()(())))))(((()))))))()))(((())...

output:

48162246

result:

ok single line: '48162246'

Test #65:

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

input:

7
((())))
1 2
1 3
1 4
4 5
1 6
6 7

output:

6

result:

ok single line: '6'

Test #66:

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

input:

100000
()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()(...

output:

2500000000

result:

ok single line: '2500000000'

Extra Test:

score: 0
Extra Test Passed