hihoCoder Challenge 20 register

Ended

Participants:577

Verdict:Accepted
Submitted:2016-05-06 19:38:03

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<iostream>
#include<cstring>
#define ll long long
#define M 1000009
using namespace std;
int a[M],f[M],n;
ll b[M];
char ch[M];
ll dfs(int x)
{
    if(f[x])
      return b[x];
    int a1=0;
    for(int i=x;i<=n;i++)
      {
        a1+=a[i];
        if(a1==-1)
          break;
        if(a1==0)
          {
            b[x]=dfs(i+1)+1;
            break;
          }
      }
    f[x]=1;
    return b[x];
}
int main()
{
    scanf("%s",ch+1);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX