Submission #232473

#TimeUsernameProblemLanguageResultExecution timeMemory
232473VEGAnnParametriziran (COCI19_parametriziran)C++14
11 / 110
1311 ms49752 KiB
#include <bits/stdc++.h> #define ft first #define sd second #define sz(x) ((int)x.size()) using namespace std; typedef long long ll; const int N = 50100; unordered_map<string, int> mem[(1 << 6)]; string s[N], t; int n, m, kol[(1 << 6)]; ll ans = 0; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); #ifdef _LOCAL freopen("in.txt","r",stdin); #endif // _LOCAL cin >> n >> m; for (int i = 0; i < n; i++){ cin >> s[i]; for (int msk = 1; msk < (1 << m); msk++){ t = ""; bool bad = 0; for (int j = 0; j < m && !bad; j++) if (msk & (1 << j)) { if (s[i][j] == '?') bad = 1; else t += s[i][j]; } if (!bad) { mem[msk][t]++; kol[msk]++; } } } for (int i = 0; i < n; i++){ int cur = n - 1; for (int msk = 1; msk < (1 << m); msk++){ t = ""; bool bad = 0; for (int j = 0; j < m && !bad; j++) if (msk & (1 << j)) { if (s[i][j] == '?') bad = 1; else t += s[i][j]; } if (!bad) cur += ((kol[msk] - mem[msk][t]) * (__builtin_parity(msk) ? -1 : 1)); } ans += cur; } assert(ans % 2 == 0); cout << ans / 2; 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...