# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
96669 | 2019-02-10T17:24:10 Z | keko37 | Parametriziran (COCI19_parametriziran) | C++14 | 460 ms | 3184 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 2296 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 2168 KB | Output is correct |
2 | Correct | 10 ms | 2052 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 2168 KB | Output is correct |
2 | Correct | 13 ms | 2296 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 2428 KB | Output is correct |
2 | Correct | 15 ms | 2084 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 28 ms | 2556 KB | Output is correct |
2 | Correct | 25 ms | 2140 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 64 ms | 3164 KB | Output is correct |
2 | Correct | 34 ms | 2168 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 111 ms | 2524 KB | Output is correct |
2 | Correct | 51 ms | 2172 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 161 ms | 3184 KB | Output is correct |
2 | Correct | 141 ms | 2572 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 286 ms | 2808 KB | Output is correct |
2 | Correct | 101 ms | 2168 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 460 ms | 2808 KB | Output is correct |
2 | Correct | 306 ms | 2552 KB | Output is correct |