Problem:
Score : 200 points

Problem Statement

The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen -, and the other characters are digits from 0 through 9.

You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.

Constraints

1≤A,B≤5

|S|=A+B+1

S consists of - and digits from 0 through 9.

Input

Input is given from Standard Input in the following format:

A B
S

Output

Print Yes if S follows the postal code format in AtCoder Kingdom; print No otherwise.

Sample Input 1

3 4
269-6650

Sample Output 1

Yes

The (A+1)-th character of S is -, and the other characters are digits from 0 through 9, so it follows the format.

Sample Input 2

1 1
---

Sample Output 2

No

S contains unnecessary -s other than the (A+1)-th character, so it does not follow the format.

Sample Input 3

1 2
7444

Sample Output 3

No

Solution in C (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define OK 0
#define ERR 1
#define INVALID -1
int CountSp(char *,char );
int IsDigit(char *);
int Check(char *,int ,int ,int );
int Judge(char *,int ,int );
int IsDigit(char *s)
{
    int cnt=0;
    while(*s)
    {
        if(*s>='0'&&*s<='9')
        {
            cnt++;
        }
        else
        {
            return INVALID;
        }
        s++;
    }
    return cnt;
}
int CountSp(char *str,char sp)
{
    int cnt=0;
    while(*str)
    {
        if(*str==sp)
        {
            cnt++;
        }
        str++;
    }
    return cnt;
}
int Check(char *str,int A,int B,int p)
{
    int len=strlen(str);
    int cnt=IsDigit(str);
    int flag=0;
    if(len!=A+B+1)
    {
        return ERR;
    }
    switch(p)
    {
    case 1:
        if(cnt==A)
        {
            flag=1;
        }
        break;
    case 2:
        if(cnt==B)
        {
            flag=1;
        }
        break;
    default:
        flag=0;
        break;
    }
    return (flag==1)?OK:ERR;
}
int Judge(char *buf,int A,int B)
{
    char *num;
    int sp,p;
    char *tmp;
    num=(char *)malloc((A+B+2)*sizeof(char));
    if(num==NULL)
    {
        printf("Not enough memory.\n");
        exit(1);
    }
    sp=CountSp(num,'-');
    if(strlen(buf)==A+B+1&&sp==1)
    {
        strcpy(num,buf);
    }
    else
    {
        return ERR;
    }
    p=1;
    tmp=strtok(num,"-");
    while(tmp!=NULL)
    {
        if(Check(num,A,B,p)==ERR)
        {
            return ERR;
        }
        tmp=strtok(NULL,"-");
        p++;
    }
    free(num);
    return OK;
}
int main()
{
    char *a;
    int A,B,r;
    scanf("%d%d",&A,&B);
    a=(char *)malloc((A+B+1)*sizeof(char));
    if(a==NULL)
    {
        printf("Not enough memory.\n");
        exit(1);
    }
    scanf("%s",a);
    r=Judge(a,A,B);
    if(r==OK)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    free(a);
    return 0;
}