Right output when "Run as custom input" for input-> 82 t t p t P 571900


#1

#include

#define ll long long int

using namespace std;

class dta{
public:
ll val,mini;
dta(){
val=-1;
mini=INT_MAX;
}
};

int mincur=INT_MAX;

stack s1;

MinStack::MinStack() {
while(!s1.empty()){
s1.pop();
}
}

void MinStack::push(int x) {
dta d;
d.val=x;
d.mini=min(mincur,x);
mincur=min(mincur,x);
s1.push(d);
}

void MinStack::pop() {
if(s1.empty()){
return;
}
s1.pop();
//update mincur
if(s1.empty()==1){
mincur=INT_MAX;
}
else{
mincur=s1.top().mini;
}
}

int MinStack::top() {
if(s1.empty()==1){
return -1;
}
return s1.top().val;
}

int MinStack::getMin() {
if(s1.empty()==1){
return -1;
}
return s1.top().mini;
}
Input:
82 t t p t P 571900535 P 884319658 g p t g p P 978982686 t g P 17441898 t t P 758134868 g g g p P 327114436 P 818490441 P 484181775 t t p P 443260408 g p p P 937420020 P 130137695 P 805351855 t P 156070325 P 741494110 p p p g P 131745858 p p p t g t p P 66193481 g p p t p p g p t p t t t P 649426185 P 172487881 P 747843291 p g p t t t P 14145170 P 804681602 g P 308433399 t t P 302683249 g t

On submitting, following output is generated:
-1 -1 -1 161337736 571900535 161337736 978982686 978982686 17441898 17441898 17441898 17441898 17441898 484181775 484181775 17441898 805351855 17441898 327114436 17441898 327114436 17441898 978982686 -1 -1 -1 -1 -1 172487881 649426185 649426185 649426185 14145170 308433399 308433399 14145170 302683249

but on running as custom input, this is generated:
-1 -1 -1 571900535 571900535 571900535 978982686 978982686 17441898 17441898 17441898 17441898 17441898 484181775 484181775 17441898 805351855 17441898 327114436 17441898 327114436 17441898 978982686 -1 -1 -1 -1 -1 172487881 649426185 649426185 649426185 14145170 308433399 308433399 14145170 302683249

I cleared my stack also, where is the problem now?Please suggest possible corrections._