I am getting SIGCONT error while running the code in codechef ide whereas on my local ide the same code runs fine.
The problem code is "TYPING" and it is from Snackdown Practice Contest: Beginner.
The code is below:
#include <iostream>
#include <iterator>
#include <map>
#include <string>
typedef long long ll;
ll FindCount(const char* str,ll num){
char previous =str[0];
ll individual_count=2;
for(ll i =1 ;i<num;i++){
if(previous=='d'||previous=='f'){
if(str[i]=='d'||str[i]=='f'){
individual_count+=4;
}
else{
individual_count+=2;
}
}
else{
if(str[i]=='j'||str[i]=='k'){
individual_count+=4;
}
else{
individual_count+=2;
}
}
previous=str[i];
}
return individual_count;
}
int main()
{
ll t;
std::cin>>t;
while(t--)
{
std::map<std::string,ll> m;
ll count=0;
ll n=0;
std::cin>>n;
while(n--){
std::string str;
std::cin>>str;
std::map<std::string,ll>::iterator itr;
itr=m.find(str);
if(itr!=m.end()){
count+=(itr->second)/2;
}
else{
ll num = str.size();
ll temp = FindCount(str.c_str(),num);
count+=temp;
m.insert({str,temp});
}
}
std::cout<<count<<"\n";
}
return 0;
}
The link to the problem statement is: https://www.codechef.com/SDPCB21/problems/TYPING
I am getting an infinite number of '0' as output each on new line.
Please tell me if there is any logical error or error of any kind in the code.
Thankyou.