• + 0 comments
    import java.util.*;
    
    public class Solution {
    
        public static void main(String[] args) {
            /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
            
            Scanner scanner = new Scanner(System.in);
            
            Set<String> uNames = new HashSet<>();
            int count = scanner.nextInt();
            for (int ii = 0; ii < count; ii++) {
                String name1 = scanner.next();
                String name2 = scanner.next();
                // This is wrong in the problem statement for "Test case 5" where
                // (a,b) is the same as (b,a)
                // addressing this symmetry here
                if (!uNames.contains(name1.concat(" ").concat(name2))
                 && !uNames.contains(name2.concat(" ").concat(name1))) {
                    uNames.add(name1.concat(" ").concat(name2));    
                 }
                
                System.out.println(uNames.size());
            }
            
            scanner.close();
        }
    }