結果
| 問題 | No.1994 Confusing Name |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-24 19:38:56 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 266 ms / 2,000 ms |
| + 747µs | |
| コード長 | 751 bytes |
| 記録 | |
| コンパイル時間 | 2,727 ms |
| コンパイル使用メモリ | 361,960 KB |
| 実行使用メモリ | 22,576 KB |
| 最終ジャッジ日時 | 2026-10-24 19:39:05 |
| 合計ジャッジ時間 | 8,475 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge6_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<string> a(n), b;
b.reserve(10 * n);
for(auto &&s : a){
cin >> s;
for(int j = 0; j < (int)s.size(); j++){
char org = s[j];
s[j] = '?';
b.emplace_back(s);
s[j] = org;
}
}
sort(b.begin(), b.end());
vector<int> cnt(b.size());
for(int i = 0; i < b.size(); ){
int p = i++;
while(i < b.size() && b[i] == b[p]) i++;
cnt[p] = i - p;
}
for(auto &&s : a){
int ans = -s.size();
for(int j = 0; j < (int)s.size(); j++){
char org = s[j];
s[j] = '?';
int p = lower_bound(b.begin(), b.end(), s) - b.begin();
ans += cnt[p];
s[j] = org;
}
cout << ans << '\n';
}
}