@@ -0,0 +1,1163 @@
+import java.util.ArrayList;%0Aimport java.util.Collections;%0Aimport java.util.List;%0Aimport java.util.Map;%0Aimport java.util.Scanner;%0Aimport java.util.TreeMap;%0A%0Apublic class Main %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A%0A        Scanner sc = new Scanner(System.in);%0A%0A        Map%3CString, List%3CInteger%3E%3E index = new TreeMap%3CString, List%3CInteger%3E%3E();%0A%0A        while (sc.hasNext()) %7B%0A%0A            String word = sc.next();%0A%0A            int page = sc.nextInt();%0A            List%3CInteger%3E pageList = null;%0A%0A            if (index.containsKey(word)) %7B%0A                pageList = index.get(word);%0A            %7D else %7B%0A                pageList = new ArrayList%3CInteger%3E();%0A            %7D%0A%0A            pageList.add(page);%0A            index.put(word, pageList);%0A%0A        %7D%0A%0A        for (String word : index.keySet()) %7B%0A%0A            System.out.println(word);%0A%0A            StringBuilder sb = new StringBuilder();%0A%0A            List%3CInteger%3E pageList = index.get(word);%0A            Collections.sort(pageList);%0A%0A            for (int page : pageList) %7B%0A                sb.append(page + %22 %22);%0A            %7D%0A%0A            System.out.println(sb.toString().trim());%0A%0A        %7D%0A%0A    %7D%0A%0A%7D%0A

Create : 0105