結果

問題 No.2737 Compound Word
ユーザー tentententen
提出日時 2024-04-22 12:50:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 1,527 bytes
コンパイル時間 4,368 ms
コンパイル使用メモリ 80,476 KB
実行使用メモリ 51,592 KB
最終ジャッジ日時 2024-04-22 12:50:42
合計ジャッジ時間 5,422 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
50,472 KB
testcase_01 AC 62 ms
50,464 KB
testcase_02 AC 61 ms
50,640 KB
testcase_03 AC 60 ms
50,684 KB
testcase_04 AC 62 ms
50,460 KB
testcase_05 AC 62 ms
50,064 KB
testcase_06 AC 60 ms
50,616 KB
testcase_07 AC 61 ms
50,156 KB
testcase_08 AC 62 ms
50,588 KB
testcase_09 AC 88 ms
51,180 KB
testcase_10 AC 78 ms
51,196 KB
testcase_11 AC 62 ms
50,488 KB
testcase_12 AC 62 ms
50,280 KB
testcase_13 AC 63 ms
50,484 KB
testcase_14 AC 60 ms
50,572 KB
testcase_15 AC 60 ms
50,412 KB
testcase_16 AC 66 ms
50,704 KB
testcase_17 AC 68 ms
50,728 KB
testcase_18 AC 66 ms
50,788 KB
testcase_19 AC 62 ms
50,628 KB
testcase_20 AC 69 ms
50,964 KB
testcase_21 AC 66 ms
50,416 KB
testcase_22 AC 64 ms
50,284 KB
testcase_23 AC 62 ms
50,232 KB
testcase_24 AC 75 ms
50,520 KB
testcase_25 AC 64 ms
50,372 KB
testcase_26 AC 74 ms
51,208 KB
testcase_27 AC 64 ms
50,616 KB
testcase_28 AC 89 ms
51,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        String[] names = new String[n];
        for (int i = 0; i < n; i++) {
            names[i] = sc.next();
        }
        Set<String> counts = new HashSet<>();
        for (String x : names) {
            for (String y : names) {
                if (x.equals(y)) {
                    continue;
                }
                counts.add(x + y);
            }
        }
        System.out.println(counts.size());
    }
}
class Scanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
        } catch (Exception e) {
            
        }
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    
    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
    
    public String next() {
        try {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return st.nextToken();
        }
    }
    
}
0