結果

問題 No.2737 Compound Word
ユーザー vjudge1
提出日時 2024-04-27 05:36:40
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 698 bytes
コンパイル時間 1,486 ms
コンパイル使用メモリ 106,052 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-15 06:07:07
合計ジャッジ時間 2,567 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <unordered_set>
#include <vector>

int count_possible_strings(int N, std::vector<std::string>& strings) {
  std::unordered_set<std::string> possible_strings;
  possible_strings.reserve(N * (N - 1));
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      possible_strings.insert(strings[i] + strings[j]);
      possible_strings.insert(strings[j] + strings[i]);
    }
  }
  return possible_strings.size();
}

int main() {
  int N;
  std::cin >> N;
  std::vector<std::string> strings(N);
  strings.reserve(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> strings[i];
  }
  std::cout << count_possible_strings(N, strings) << std::endl;
  return 0;
}
0