# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
198861 | 2020-01-27T22:20:26 Z | ZwariowanyMarcin | Parametriziran (COCI19_parametriziran) | C++14 | 184 ms | 2040 KB |
#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(); LL res = 0; int p = (m1 & m2); for (auto it : v[m1]) x[daj(it, p)]++; for (auto it : v[m2]) res += x[daj(it, p)]; if (m1 != m2) ans += res; else ans += (res - ss(v[m1])) / 2; } printf ("%lld", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 1140 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 888 KB | Output is correct |
2 | Correct | 10 ms | 888 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 1016 KB | Output is correct |
2 | Correct | 13 ms | 1400 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 1144 KB | Output is correct |
2 | Correct | 13 ms | 1016 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 1400 KB | Output is correct |
2 | Correct | 16 ms | 888 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 2040 KB | Output is correct |
2 | Correct | 23 ms | 1272 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 1272 KB | Output is correct |
2 | Correct | 26 ms | 1016 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 70 ms | 1912 KB | Output is correct |
2 | Correct | 52 ms | 1656 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 112 ms | 1508 KB | Output is correct |
2 | Correct | 52 ms | 1144 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 184 ms | 1788 KB | Output is correct |
2 | Correct | 130 ms | 1736 KB | Output is correct |