Submission #862186

#TimeUsernameProblemLanguageResultExecution timeMemory
862186TAhmed33Set (COCI21_set)C++98
10 / 110
1096 ms500 KiB
#include <bits/stdc++.h> using namespace std; int op (string a, string b) { int ret = 0; for (int i = 0; i < (int)a.length(); i++) { ret *= 3; if (a[i] == b[i]) ret += a[i] - '0'; else { set <char> x = {'1', '2', '3'}; x.erase(a[i]); x.erase(b[i]); ret += *(x.begin()) - '0'; } } return ret; } int freq[6563]; string arr[2188]; int hashh (string s) { reverse(s.begin(), s.end()); int cnt = 0; while (s.length()) { cnt *= 3; cnt += (s.back() - '0'); s.pop_back(); } return cnt; } int main () { int n, m; cin >> n >> m; for (int i = 0; i < n; i++) cin >> arr[i]; for (int i = 0; i < n; i++) freq[hashh(arr[i])]++; long long ans = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i == j) continue; ans += freq[op(arr[i], arr[j])]; if (arr[i] == arr[j]) ans -= 2; } } ans /= 6; cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...