Submission #862185

#TimeUsernameProblemLanguageResultExecution timeMemory
862185TAhmed33Set (COCI21_set)C++98
10 / 110
1068 ms150352 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; 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++) { unordered_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 += freq2[arr[i]] * (freq2[arr[i]] - 1) / 2; } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...