Submission #444467

#TimeUsernameProblemLanguageResultExecution timeMemory
444467zxcvbnmParametriziran (COCI19_parametriziran)C++14
88 / 110
1510 ms65540 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; map<string, int> cnt; vector<string> a(n); for(int i = 0; i < n; i++) { string str; cin >> str; a[i] = str; for(int mask = 0; mask < (1 << m); mask++) { string s = str; for(int j = 0; j < m; j++) { if (mask & (1 << j)) { s[j] = '*'; } } cnt[s]++; } } ll ans = 0; for(string str : a) { vector<int> idx; for(int i = 0; i < m; i++) { if (isalpha(str[i])) { idx.push_back(i); } } int letters = idx.size(); string str2 = str; for(char& c : str2) { if (c == '?') { c = '*'; } } for(int mask = 0; mask < (1 << letters); mask++) { string s = str2; for(int j = 0; j < letters; j++) { if (mask & (1 << j)) { s[idx[j]] = '?'; } } // cout << s << " "; // cout << cnt[s] << "\n"; ans += cnt[s]; } // cerr << "\n"; } ans -= n; ans /= 2; cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...