結果

問題 No.2737 Compound Word
ユーザー tnakao0123
提出日時 2024-04-30 18:50:54
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 681 bytes
コンパイル時間 935 ms
コンパイル使用メモリ 70,712 KB
最終ジャッジ日時 2025-02-21 09:54:50
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:29:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   29 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
main.cpp:32:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   32 |     scanf("%s", s);
      |     ~~~~~^~~~~~~~~

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2737.cc:  No.2737 Compound Word - yukicoder
 */

#include<cstdio>
#include<string>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_N = 50;
const int MAX_L = 100;

/* typedef */

/* global variables */

string ss[MAX_N], ts[MAX_N * MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    char s[MAX_L + 4];
    scanf("%s", s);
    ss[i] = string(s);
  }

  int m = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (i != j) ts[m++] = ss[i] + ss[j];

  sort(ts, ts + m);
  m = unique(ts, ts + m) - ts;

  printf("%d\n", m);
  
  return 0;
}
0