結果

問題 No.1994 Confusing Name
ユーザー shoshoshomshoshoshom
提出日時 2022-07-01 22:43:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,047 bytes
コンパイル時間 2,904 ms
コンパイル使用メモリ 207,852 KB
実行使用メモリ 12,388 KB
最終ジャッジ日時 2024-05-04 17:07:00
合計ジャッジ時間 6,213 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
12,388 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

static inline void solve() {
  int n;
  cin >> n;
  vector<vector<pair<int, string>>> S(11);
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    S[s.size()].push_back({i, s});
  }
  vector<int> ans(n, 0);
  for (int len = 1; len <= 10; len++) {
    int m = S[len].size();
    for (int i = 0; i < m; i++) {
      string& a = S[len][i].second;
      int x = S[len][i].first;
      for (int j = i + 1; j < m; j++) {
        string& b = S[len][j].second;
        int y = S[len][j].first;
        int diffs = 0;
        for (int k = 0; k < len; k++) {
          if (a[k] != b[k]) {
            diffs++;
          }
        }
        if (diffs == 1) {
          ans[x]++;
          ans[y]++;
        }
      }
    }
  }
  for (int a: ans) {
    cout << a << '\n';
  }
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
#ifdef LOCAL
  int T;
  cin >> T;
  for (int tc = 1; tc <= T; tc++) {
    cout << "Case" << tc << ":" << '\n';
    solve();
  }
#else
  solve();
#endif
  return 0;
}
0