# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
96669 | keko37 | Parametriziran (COCI19_parametriziran) | C++14 | 460 ms | 3184 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef long long llint;
const int MAXN = 50005;
llint n, m, sol;
string s[MAXN];
vector <int> v[70];
unordered_map <llint, int> mp;
void spoji (int m1, int m2) {
mp.clear();
for (int i=0; i<v[m1].size(); i++) {
llint h = 0;
for (int j=0; j<m; j++) {
if ((m1 & (1 << j)) && (m2 & (1 << j))) {
h = h * 27 + s[v[m1] [i]] [j] - 'a';
}
}
mp[h]++;
}
for (int i=0; i<v[m2].size(); i++) {
llint h = 0;
for (int j=0; j<m; j++) {
if ((m1 & (1 << j)) && (m2 & (1 << j))) {
h = h * 27 + s[v[m2] [i]] [j] - 'a';
}
}
sol += mp[h];
}
}
int main () {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
for (int i=1; i<=n; i++) {
cin >> s[i];
int mask = 0;
for (int j=0; j<m; j++) {
if (s[i] [j] != '?') mask += (1 << j);
}
v[mask].push_back(i);
}
for (int m1=0; m1<(1 << m); m1++) {
for (int m2=0; m2<(1 << m); m2++) {
spoji(m1, m2);
}
}
cout << (sol - n)/2;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |