Last active
March 7, 2020 12:29
-
-
Save dalcon10028/21a82093b7d8bcfb9602edbd3f4206a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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