Submission #96690

#TimeUsernameProblemLanguageResultExecution timeMemory
96690ShtefParametriziran (COCI19_parametriziran)C++14
110 / 110
1474 ms5640 KiB
#include <iostream> #include <vector> #include <map> using namespace std; typedef long long ll; int n, m; string s[50005]; vector <string> a[(1 << 7) + 5]; ll sol; ll processmaskpair(int x, int y){ map <string, ll> c; for(vector <string>::iterator i = a[x].begin() ; i != a[x].end() ; ++i){ string o = *i; string t = ""; for(int j = 0 ; j < m ; ++j){ if((x & (1 << j)) && (y & (1 << j))){ t += o[j]; } } c[t]++; } ll ret = 0; for(vector <string>::iterator i = a[y].begin() ; i != a[y].end() ; ++i){ string o = *i; string t = ""; for(int j = 0 ; j < m ; ++j){ if((x & (1 << j)) && (y & (1 << j))){ t += o[j]; } } ret += c[t]; } return ret; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m; for(int i = 0 ; i < n ; ++i){ cin >> s[i]; } for(int i = 0 ; i < n ; ++i){ int mask = 0; for(int j = 0 ; j < m ; ++j){ if(s[i][j] != '?'){ mask |= (1 << j); } } a[mask].push_back(s[i]); } for(int i = 0 ; i < (1 << m) ; ++i){ for(int j = 0 ; j < (1 << m) ; ++j){ sol += processmaskpair(i, j); } } sol -= n; sol /= 2; cout << sol << endl; 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...