Skip to content

Instantly share code, notes, and snippets.

@dalcon10028
Last active March 7, 2020 12:29
Show Gist options
  • Select an option

  • Save dalcon10028/21a82093b7d8bcfb9602edbd3f4206a5 to your computer and use it in GitHub Desktop.

Select an option

Save dalcon10028/21a82093b7d8bcfb9602edbd3f4206a5 to your computer and use it in GitHub Desktop.
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t =sc.nextInt();
for(int i=0; i<t; i++){
HashMap<String, Integer> map = new HashMap<>();
int n=sc.nextInt();
for(int j=0; j<n; j++){
sc.next();
String str = sc.next();
if(map.containsKey(str)) map.put(str, map.get(str)+1);
else map.put(str, 1);
}
int result = 1;
for (int j : map.values())
result*= j+1;
System.out.println(result-1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment