# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
198860 | ZwariowanyMarcin | Parametriziran (COCI19_parametriziran) | C++14 | 177 ms | 2296 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>
#define fi first
#define se second
#define mp make_pair
#define ss(x) (int) x.size()
#define pb push_back
#define LL long long
#define ld long double
#define cat(x) cerr << #x << " = " << x << endl
#define FOR(i, j, n) for(int i = j; i <= n; ++i)
#define boost cin.tie(0), ios_base::sync_with_stdio(0);
using namespace std;
const int nax = 50005;
int n, m;
char s[nax][10];
vector <int> v[64];
LL ans;
unordered_map <int, int> x;
int daj(int nr, int mask) {
int y = 0;
for (int i = 0; i < m; ++i) {
y *= 26;
if ((mask >> i) & 1)
y += (s[nr][i] - 'a');
}
return y;
}
int main() {
scanf ("%d%d", &n, &m);
for (int i = 0; i < n; ++i) {
scanf ("%s", s[i]);
int mask = 0;
for (int j = 0; j < m; ++j)
if (s[i][j] != '?')
mask += 1 << j;
v[mask].pb(i);
}
for (int m1 = 0; m1 < (1 << m); ++m1)
for (int m2 = m1; m2 < (1 << m); ++m2) {
x.clear();
int p = (m1 & m2);
for (auto it : v[m1])
x[daj(it, p)]++;
for (auto it : v[m2])
ans += x[daj(it, p)];
}
printf ("%lld", ans - n);
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... |