Submission #874558

#TimeUsernameProblemLanguageResultExecution timeMemory
874558Youssif_ElkadiSet (COCI21_set)C++17
40 / 110
1095 ms65208 KiB
#include <bits/stdc++.h> using namespace std; const long long N = 5e2 + 5, inf = 1e17 + 5, mod = 998244353; int main() { ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL); int n, kk; cin >> n >> kk; vector<string> arr(n); map<string, int> mp; for (int i = 0; i < n; i++) cin >> arr[i], mp[arr[i]]++; int cnt = 0; for (int i = 0; i < n - 1; i++) { mp[arr[i]]--; for (int j = i + 1; j < n; j++) { mp[arr[j]]--; string need = ""; for (int k = 0; k < kk; k++) { if (arr[i][k] == arr[j][k]) need.push_back(arr[i][k]); else if (arr[i][k] != '1' && arr[j][k] != '1') need.push_back('1'); else if (arr[i][k] != '2' && arr[j][k] != '2') need.push_back('2'); else if (arr[i][k] != '3' && arr[j][k] != '3') need.push_back('3'); } cnt += mp[need]; } for (int j = i + 1; j < n; j++) mp[arr[j]]++; } cout << cnt; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...