結果
問題 | No.1994 Confusing Name |
ユーザー | tenten |
提出日時 | 2023-02-25 12:42:48 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 854 ms / 2,000 ms |
コード長 | 2,390 bytes |
コンパイル時間 | 3,664 ms |
コンパイル使用メモリ | 92,440 KB |
実行使用メモリ | 90,620 KB |
最終ジャッジ日時 | 2024-09-13 10:53:56 |
合計ジャッジ時間 | 18,236 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 54 ms
50,216 KB |
testcase_01 | AC | 54 ms
50,276 KB |
testcase_02 | AC | 53 ms
50,424 KB |
testcase_03 | AC | 53 ms
50,300 KB |
testcase_04 | AC | 53 ms
50,160 KB |
testcase_05 | AC | 82 ms
51,708 KB |
testcase_06 | AC | 105 ms
52,160 KB |
testcase_07 | AC | 59 ms
50,332 KB |
testcase_08 | AC | 100 ms
52,260 KB |
testcase_09 | AC | 103 ms
52,328 KB |
testcase_10 | AC | 93 ms
51,624 KB |
testcase_11 | AC | 88 ms
51,456 KB |
testcase_12 | AC | 695 ms
86,024 KB |
testcase_13 | AC | 791 ms
88,060 KB |
testcase_14 | AC | 743 ms
89,944 KB |
testcase_15 | AC | 706 ms
89,444 KB |
testcase_16 | AC | 614 ms
74,528 KB |
testcase_17 | AC | 707 ms
88,820 KB |
testcase_18 | AC | 764 ms
90,620 KB |
testcase_19 | AC | 837 ms
88,120 KB |
testcase_20 | AC | 809 ms
88,752 KB |
testcase_21 | AC | 270 ms
60,400 KB |
testcase_22 | AC | 208 ms
58,192 KB |
testcase_23 | AC | 854 ms
89,028 KB |
testcase_24 | AC | 807 ms
80,648 KB |
testcase_25 | AC | 575 ms
70,308 KB |
testcase_26 | AC | 326 ms
53,624 KB |
testcase_27 | AC | 822 ms
81,140 KB |
testcase_28 | AC | 576 ms
70,924 KB |
testcase_29 | AC | 192 ms
46,108 KB |
testcase_30 | AC | 643 ms
72,436 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>> all = new ArrayList<>(); HashMap<String, Integer> counts = new HashMap<>(); for (int i = 0; i < n; i++) { char[] inputs = sc.next().toCharArray(); char save; ArrayList<String> tmp = new ArrayList<>(); for (int j = 0; j < inputs.length; j++) { save = inputs[j]; inputs[j] = '?'; String current = new String(inputs); tmp.add(current); counts.put(current, counts.getOrDefault(current, 0) + 1); inputs[j] = save; } all.add(tmp); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { int ans = 0; for (String x : all.get(i)) { 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(); } }