結果

問題 No.1994 Confusing Name
ユーザー erbowlerbowl
提出日時 2022-08-07 16:30:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 607 ms / 2,000 ms
コード長 852 bytes
コンパイル時間 2,336 ms
コンパイル使用メモリ 222,008 KB
実行使用メモリ 34,500 KB
最終ジャッジ日時 2023-10-17 11:27:03
合計ジャッジ時間 12,133 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 4 ms
4,348 KB
testcase_06 AC 7 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 5 ms
4,348 KB
testcase_09 AC 7 ms
4,348 KB
testcase_10 AC 4 ms
4,348 KB
testcase_11 AC 4 ms
4,348 KB
testcase_12 AC 449 ms
24,468 KB
testcase_13 AC 556 ms
32,652 KB
testcase_14 AC 587 ms
33,444 KB
testcase_15 AC 454 ms
28,428 KB
testcase_16 AC 373 ms
25,524 KB
testcase_17 AC 439 ms
28,164 KB
testcase_18 AC 602 ms
34,236 KB
testcase_19 AC 604 ms
34,236 KB
testcase_20 AC 607 ms
34,500 KB
testcase_21 AC 87 ms
9,420 KB
testcase_22 AC 39 ms
6,484 KB
testcase_23 AC 489 ms
28,956 KB
testcase_24 AC 486 ms
28,164 KB
testcase_25 AC 276 ms
19,452 KB
testcase_26 AC 126 ms
11,532 KB
testcase_27 AC 426 ms
26,316 KB
testcase_28 AC 300 ms
20,772 KB
testcase_29 AC 31 ms
6,032 KB
testcase_30 AC 345 ms
22,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    ll n;
    std::cin >> n;
    vector<map<string,ll>> msame(11);
    vector<string> ori(n);
    vector<vector<map<string,ll>>> ms(11,vector<map<string,ll>>(11));
    for (int i = 0; i < n; i++) {
        string s;
        std::cin >> s;
        ori[i] = s;
        msame[s.size()][s]++;
        for (int j = 0; j < s.size(); j++) {
            ms[s.size()][j][s.substr(0,j)+s.substr(j+1,s.size()-j-1)]++;
        }
    }
    for (int i = 0; i < n; i++) {
        ll ans = 0;
        string s = ori[i];
        for (int j = 0; j < s.size(); j++) {
            ans += ms[s.size()][j][s.substr(0,j)+s.substr(j+1,s.size()-j-1)]-1;
        }
        ans -= msame[s.size()][s]-1;
        std::cout << ans << std::endl;
    }
}
0