Weirdo help!

what could possibly be wrong.

while(t–>0) {
int n = in.nextInt();
String[] arr = new String[n];
//int mx = Integer.MIN_VALUE;
for(int i=0;i<n;i++) {
arr[i] = in.nextString();
//if(arr[i].length()>mx) mx = arr[i].length();
}
ArrayList alice = new ArrayList<>();
ArrayList bob = new ArrayList<>();
int[][] ch = new int[n][26];
for(int i=0;i<n;i++) {
int flag=0;
for(int j=0;j<arr[i].length();j++) {
if(!isVowel(arr[i].charAt(j))) {
if(j==0) {
if(!isVowel(arr[i].charAt(j+1))) flag=1;
}
else if(j==arr[i].length()-1) {
if(!isVowel(arr[i].charAt(j-1))) flag=1;
}
else {
if(!(isVowel(arr[i].charAt(j-1))&&isVowel(arr[i].charAt(j+1)))) flag=1;
}
}
else {
if(j>0&&j<arr[i].length()-1) {
if(isVowel(arr[i].charAt(j-1))||isVowel(arr[i].charAt(j+1))) {}
else flag=1;
}
}
ch[i][arr[i].charAt(j)-‘a’]++;
}
if(flag==0)alice.add(i);
else bob.add(i);
}
int la = alice.size();
int lb = bob.size();
long[] count1 = new long[26];
long[] count2 = new long[26];
long haha[] = new long[26];
long hehe[] = new long[26];
for(int i=0;i<la;i++) {
int ind = alice.get(i);
for(int j=0;j<26;j++) {
if(ch[ind][j]>0) {
haha[j]+=(long)ch[ind][j];
count1[j]++;
}
}
}
for(int i=0;i<lb;i++) {
int ind = bob.get(i);
for(int j=0;j<26;j++) {
if(ch[ind][j]>0) {
count2[j]++;
hehe[j]+=(long)ch[ind][j];
}
}
}
double aa = 1;
double bb = 1;
double cc = 1;
double dd = 1;
for(int i=0;i<26;i++) {
if(count1[i]>0) {
aa*=count1[i];
cc*=haha[i];
}
if(count2[i]>0) {
bb*=count2[i];
dd*=hehe[i];
}
}
// double mc = Math.pow(cc, la);
// double bc = Math.pow(dd, lb);
int flag=0;
while(la>0) {
if(aa/cc<Math.pow(10, -200)) {
if(lb>0) {
aa*=dd;
lb–;
}
else if(lb==0) {
flag=1;
sb.append(“0”).append("\n");
break;
}
}
else {
aa/=cc;
la–;
}
}
if(flag==1) continue;
while(lb>0) {
aa*=dd;
lb–;
if(aa>Math.pow(10, 7)) {
flag=1;
sb.append(“Infinity”).append("\n");
break;
}
}
if(flag==1) continue;
aa/=bb;
df.setRoundingMode(RoundingMode.HALF_UP);
sb.append(df.format(aa)).append("\n");
}

there is no error in checking vowel’s portion. Error is being generated in the calculation part. I know using log would help but just want to know why is this code wrong.

well did u submit and what kind of verdict did u get,friend?

1 Like

it was wrong answer

did the first two subtasks got an AC or that too WA?

I think it was WA too, but by using normal power function i was able to pass the first two

use log for 2nd subtasks to get AC since the floating points are very high which will be rounded off to 0 at times

I know using log would help, but why is my solution wrong, that’s what i am asking

ok lemme see and check friend