結果

問題 No.1994 Confusing Name
ユーザー MasKoaTS
提出日時 2022-02-23 16:40:03
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 891 ms / 2,000 ms
コード長 748 bytes
コンパイル時間 1,017 ms
コンパイル使用メモリ 85,464 KB
最終ジャッジ日時 2025-01-28 01:30:10
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#define rep(i, l, n) for (int i = (l); i < (n); i++)
using namespace std;
using str = string;
template <class T>
using V = vector<T>;


int main(void) {
	int n;	cin >> n;
	V<str> s(n);
	map<str, int> mp = {};
	rep(i, 0, n) {
		cin >> s[i];
		rep(j, 0, s[i].size()) {
			str t = "";
			rep(k, 0, s[i].size()) {
				if (j == k) {
					t.push_back('.');
				}
				else {
					t.push_back(s[i][k]);
				}
			}
			mp[t]++;
		}
	}

	V<int> ans(n);
	rep(i, 0, n) {
		rep(j, 0, s[i].size()) {
			str t = "";
			rep(k, 0, s[i].size()) {
				if (j == k) {
					t.push_back('.');
				}
				else {
					t.push_back(s[i][k]);
				}
			}
			ans[i] += mp[t] - 1;
		}
		cout << ans[i] << endl;
	}

	return 0;
}
0