Submission #111918

#TimeUsernameProblemLanguageResultExecution timeMemory
111918fredbrParametriziran (COCI19_parametriziran)C++17
33 / 110
3080 ms1840 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3", "unroll-loops") #pragma GCC target("popcnt") using namespace std; int k; struct Word { unsigned v[6]; Word() = default; Word& operator=(string const& s) { for (int i = 0; i < k; i++) { if (s[i] == '?') v[i] = 0; else v[i] = 1u<<(s[i]-'a'); } return *this; } inline bool ok(Word const& rhs) const { for (int i = 0; i < k; i++) { if (__builtin_popcount(v[i]^rhs.v[i]) == 2) return false; } return true; } }; int const maxn = 50505; Word v[maxn]; int main() { ios::sync_with_stdio(false), cin.tie(nullptr); int n; cin >> n >> k; for (int i = 0; i < n; i++) { string s; cin >> s; v[i] = s; } int ans = 0; for (int i = 0; i < n; i++) { for (int j = i+1; j < n; j++) ans += v[i].ok(v[j]); } cout << ans << "\n"; }
#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...