結果
問題 | No.1994 Confusing Name |
ユーザー | tenten |
提出日時 | 2023-04-19 14:21:54 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 893 ms / 2,000 ms |
コード長 | 2,371 bytes |
コンパイル時間 | 2,743 ms |
コンパイル使用メモリ | 91,792 KB |
実行使用メモリ | 90,528 KB |
最終ジャッジ日時 | 2024-04-22 15:13:54 |
合計ジャッジ時間 | 17,056 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
36,980 KB |
testcase_01 | AC | 51 ms
37,028 KB |
testcase_02 | AC | 52 ms
36,880 KB |
testcase_03 | AC | 50 ms
36,904 KB |
testcase_04 | AC | 50 ms
36,648 KB |
testcase_05 | AC | 84 ms
38,312 KB |
testcase_06 | AC | 105 ms
39,448 KB |
testcase_07 | AC | 56 ms
37,212 KB |
testcase_08 | AC | 95 ms
39,356 KB |
testcase_09 | AC | 104 ms
39,764 KB |
testcase_10 | AC | 76 ms
38,624 KB |
testcase_11 | AC | 79 ms
38,260 KB |
testcase_12 | AC | 735 ms
76,120 KB |
testcase_13 | AC | 795 ms
81,992 KB |
testcase_14 | AC | 865 ms
89,632 KB |
testcase_15 | AC | 737 ms
88,900 KB |
testcase_16 | AC | 619 ms
71,688 KB |
testcase_17 | AC | 707 ms
87,724 KB |
testcase_18 | AC | 893 ms
90,528 KB |
testcase_19 | AC | 822 ms
87,656 KB |
testcase_20 | AC | 801 ms
87,748 KB |
testcase_21 | AC | 238 ms
49,780 KB |
testcase_22 | AC | 186 ms
46,324 KB |
testcase_23 | AC | 812 ms
79,444 KB |
testcase_24 | AC | 832 ms
80,548 KB |
testcase_25 | AC | 542 ms
69,676 KB |
testcase_26 | AC | 286 ms
52,572 KB |
testcase_27 | AC | 850 ms
80,760 KB |
testcase_28 | AC | 555 ms
72,812 KB |
testcase_29 | AC | 181 ms
46,340 KB |
testcase_30 | AC | 535 ms
69,568 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); ArrayList<ArrayList<String>> names = new ArrayList<>(); HashMap<String, Integer> counts = new HashMap<>(); for (int i = 0; i < n; i++) { char[] values = sc.next().toCharArray(); ArrayList<String> current = new ArrayList<>(); for (int j = 0; j < values.length; j++) { char tmp = values[j]; values[j] = '?'; String s = new String(values); current.add(s); counts.put(s, counts.getOrDefault(s, 0) + 1); values[j] = tmp; } names.add(current); } StringBuilder sb = new StringBuilder(); for (ArrayList<String> current : names) { int ans = 0; for (String x : current) { ans += counts.get(x) - 1; } sb.append(ans).append("\n"); } System.out.print(sb); } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }