关于c++栈的简单问题

请问我的代码为何报runtime error?该如何修改?
题目:
https://vjudge.net/contest/518654/problemPrint/D
我的代码(c++):

#include 
#include 
#include 
#include 

using namespace std;

char c[100000]={0};
stack <char> s;
int main()
{
    //char c[30];
    int n=0;
    //stack  s;
    scanf("%s",c);
    n=strlen(c);
    if (c[0]=='+')
    {
        s.push('+');
    }
    else if (c[0]=='-')
    {
        s.push('-');
    }
    for (int i=1;iif (c[i]==s.top())
        {
            s.pop();
        }
        else
        {
            s.push(c[i]);
        }
    }
    if (s.empty()==1)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}


出错提示:

img

有一个问题,是 s.top() 调用前需要有元素在栈里面,不然会出错。一般用 stack.empty 先判断一下