Submission #232524

#TimeUsernameProblemLanguageResultExecution timeMemory
232524NONAMEParametriziran (COCI19_parametriziran)C++17
110 / 110
1559 ms5752 KiB
#include <bits/stdc++.h> #define sz(x) int(x.size()) #define in(x) freopen(x, "r", stdin) #define out(x) freopen(x, "w", stdout) #define N 100500 #define oo ll(1e16) #define ft first #define sd second #define mp make_pair #define pb push_back #define ppb pop_back #define el '\n' #define elf endl #define base ll(1e9 + 7) using namespace std; typedef long long ll; typedef long double ld; int n, m; ll ans; string s[N]; vector <int> v[128]; ll f(int x, int y) { map <string, ll> ma; ll rs = 0; for (int i = 0; i < sz(v[x]); i++) { string t = ""; for (int j = 0; j < m; j++) if (((1 << j) & x) && ((1 << j) & y)) t += s[v[x][i]][j]; ma[t]++; } for (int i = 0; i < sz(v[y]); i++) { string t = ""; for (int j = 0; j < m; j++) if (((1 << j) & x) && ((1 << j) & y)) t += s[v[y][i]][j]; rs += ma[t]; } return rs; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // in("input.txt"); cin >> n >> m; for (int i = 0; i < n; i++) { cin >> s[i]; int msk = 0; for (int j = 0; j < m; j++) if (s[i][j] != '?') msk |= (1 << j); v[msk].pb(i); } ans = -n; for (int i = 0; i < (1 << m); i++) for (int j = 0; j < (1 << m); j++) ans += f(i, j); cout << ans / 2; }
#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...