Submission #334563

#TimeUsernameProblemLanguageResultExecution timeMemory
334563dooweyParametriziran (COCI19_parametriziran)C++14
22 / 110
3086 ms65540 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define fi first #define se second #define mp make_pair #define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); const int M = 6; const int AL = 27; multiset<int> cnt[(1<<M)][(1<<M)]; int pwr[M]; int main(){ fastIO; int n, m; cin >> n >> m; pwr[0]=1; for(int i = 1; i < m ; i ++ ){ pwr[i]=pwr[i-1]*AL; } string s; int res; int clc; ll soln = 0; for(int i = 1; i <= n; i ++ ){ cin >> s; int que = 0; for(int j = 0; j < m ; j ++ ){ if(s[j] == '?') que |= (1 << j); } for(int q2 = 0 ; q2 < (1 << m) ; q2 ++ ){ res = (que | q2); clc = 0; for(int j = 0 ; j < m ; j ++ ){ if((res & (1 << j))) continue; clc += pwr[j] * 1ll * (s[j] - 'a' + 1); } soln += cnt[q2][res].count(clc); } for(int sum = 0; sum < (1 << m); sum ++ ){ if((sum & que) != que) continue; clc = 0; for(int j = 0 ; j < m ; j ++ ){ if((sum & (1 << j))) continue; clc += pwr[j] * 1ll * (s[j] - 'a' + 1); } cnt[que][sum].insert(clc); } } cout << soln << "\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...