This is my simple solution:
import java.util.Scanner;
class LCOLLIS
{
final static long[] factorial = {1,1,2,6,24,120,720,5040,40320,362880,3628800};
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
long n = scan.nextLong();
for(long i=0;i<n;i++)
{
long coll=0;
long N = scan.nextLong();
scan.nextLong();
for(long j=0;j<N;j++)
{
coll+=combinations(count1(scan.next()));
}
System.out.println(coll);
}
scan.close();
}
static long count1(String input)
{
return input.length()-(input.replaceAll("1", "").length());
}
static long combinations(long N)
{
if(N==1||N==0)
return 0;
return factorial[(int) N]/((2)*factorial[(int) (N-2)]);
}
}
I thought of using P&C here, cause I found it easy!
What’s wrong in this??
THANKS A LOOOT!!