hihoCoder Challenge 7 register

Ended

Participants:391

Verdict:Accepted
Submitted:2015-01-18 20:59:49

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>
#pragma warning(disable:4996)
using namespace std;
char s[111];
int n;
int Find(bool ll,bool rr, int l, int r) {
    //
    if (l > r)return 1;
    int bj = -1;
    for (int i = l; i <= r; i++)
        if (s[i] == '(') {
            bj = i;
            break;
        }
    int cnt = 0;
    //cout << bj << endl;
    if (bj != -1) {
        for (int i = bj; i <= r; i++)
        {
            if (s[i] == ')')cnt--;
            if (s[i] == '(')cnt++;
            if (cnt == 0) {
                //cout << bj << " " << i << endl;
                if (i == bj + 1)return 0;
                return Find(ll,1, l, bj - 1) && Find(0,0, bj + 1, i - 1) && Find(1,rr, i + 1, r);
            }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX