it is showing RE (SIGSEGV) on two test cases and working fine with rest 7 test cases.
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const ll mod = 1e9 + 7;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
ll t;
cin>>t;
while(t--){
ll n,k;
cin>>n>>k;
string s;
cin>>s;
vector<ll> v;
ll count = 0;
for(ll i=0; i<n; i++){
if(s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u'){
count++;
if(count == k){
count = 0;
i++;
ll in_between = 0;
while(s[i] != 'a' && s[i] != 'e' && s[i] != 'i' && s[i] != 'o' && s[i] != 'u' && i<n){
in_between++;
i++;
}
if(i<n){
v.push_back(in_between+1);
}
i--;
}
}
}
// cout<<"vector : ";
// for(int i=0; i<v.size(); i++){
// cout<<v[i]<<" ";
// }
// cout<<endl;
int ans = v[0];
for(int i=1; i<v.size(); i++){
ans = ((ans%mod) * (v[i]%mod))%mod;
}
cout<<ans<<endl;
}
return 0;
}
So I tried doing some changes at the end of the code but then its showing WA for those two test cases. Following is the changes that I made:
if(v.size() > 0){
int ans = v[0];
if(v.size() > 1){
for(int i=1; i<v.size(); i++){
ans = ((ans%mod) * (v[i]%mod))%mod;
}
}
cout<<(ans%mod)<<endl;
}
else{
cout<<“0”<<endl;
}