Submission #862180

#TimeUsernameProblemLanguageResultExecution timeMemory
862180TAhmed33Set (COCI21_set)C++98
10 / 110
1087 ms828 KiB
#include <bits/stdc++.h> using namespace std; string op (string a, string b) { string ret; for (int i = 0; i < (int)a.length(); i++) { if (a[i] == b[i]) ret += a[i]; else { set <char> x = {'1', '2', '3'}; x.erase(a[i]); x.erase(b[i]); ret += *(x.begin()); } } return ret; } int main () { int n, m; cin >> n >> m; map <string, int> cnt; string arr[n]; long long ans = 0; for (int i = 0; i < n; i++) { cin >> arr[i]; map <string, int> freq2; for (int j = 0; j < i; j++) { if (arr[i] == arr[j]) continue; ans += freq2[op(arr[i], arr[j])]; freq2[arr[j]]++; } ans += cnt[arr[i]] * (cnt[arr[i]] - 1) / 2; cnt[arr[i]]++; } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...