結果
問題 |
No.1994 Confusing Name
|
ユーザー |
|
提出日時 | 2022-08-07 16:30:00 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 845 ms / 2,000 ms |
コード長 | 852 bytes |
コンパイル時間 | 3,766 ms |
コンパイル使用メモリ | 212,168 KB |
最終ジャッジ日時 | 2025-01-30 19:14:32 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
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; } }