Submission #232512

#TimeUsernameProblemLanguageResultExecution timeMemory
232512VEGAnnParametriziran (COCI19_parametriziran)C++14
110 / 110
2305 ms65216 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; const int Z = 28; unordered_map<string, int> mem; string s[N], t; int n, m; 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 = 0; msk < (1 << m); msk++){ bool bad = 0; t = ""; for (int j = 0; j < m && !bad; j++) if (msk & (1 << j)) { if (s[i][j] == '?') bad = 1; else t += "#"; } else t += s[i][j]; if (!bad) mem[t]++; } } for (int i = 0; i < n; i++){ for (int msk = 0; msk < (1 << m); msk++){ t = ""; for (int j = 0; j < m; j++) if (msk & (1 << j)) { if (s[i][j] == '?') t += "#"; else t += "?"; } else t += s[i][j]; if (mem.find(t) != mem.end()) ans += mem[t]; } } cout << (ans - n) / 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...