Submission #862183

#TimeUsernameProblemLanguageResultExecution timeMemory
862183TAhmed33Set (COCI21_set)C++98
10 / 110
1060 ms150536 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; } string op2[2188][2188]; int main () { int n, m; cin >> n >> m; map <string, int> cnt; string arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) { op2[i][j] = op(arr[i], arr[j]); } } long long ans = 0; for (int i = 0; i < n; i++) { map <string, int> freq2; for (int j = 0; j < i; j++) { if (arr[i] == arr[j]) continue; ans += freq2[op2[i][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...