# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
523954 | 2022-02-08T13:09:05 Z | tube5429 | Parametriziran (COCI19_parametriziran) | C++14 | 1136 ms | 42928 KB |
#include <bits/stdc++.h> #define long long long using namespace std; int n, m; long ans; map<int, int> ls[64][64]; void solve(istream& cin) { cin >> n >> m; for(int i = 0; i < n; i++) { string s; cin >> s; int h = 0, mask1 = 0; for(int j = 0; j < m; j++) if(s[j] != '?') mask1 |= 1 << j; int tmp[64]; fill(tmp, tmp+64, -1); for(int mask2 = 0; mask2 < 1 << m; mask2++) if((mask2 & mask1) == mask2) { int h = 0; for(int j = 0, p = 1; j < m; j++, p *= 26) { if(mask2 >> j & 1) { h += p * (s[j] - 'a'); } } tmp[mask2] = h; } for(int mask2 = 0; mask2 < 1 << m; mask2++) { int and_mask = mask1 & mask2; int h = tmp[and_mask]; if(ls[mask2][and_mask].count(h)) ans += ls[mask2][and_mask][h]; } for(int mask2 = 0; mask2 < 1 << m; mask2++) if(tmp[mask2] >= 0) ++ls[mask1][mask2][tmp[mask2]]; } cout << ans; } int main() { ios::sync_with_stdio(false); cin.tie(0); solve(cin); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 588 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 588 KB | Output is correct |
2 | Correct | 10 ms | 588 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 644 KB | Output is correct |
2 | Correct | 16 ms | 632 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 1288 KB | Output is correct |
2 | Correct | 19 ms | 832 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 39 ms | 1172 KB | Output is correct |
2 | Correct | 37 ms | 1560 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 180 ms | 5568 KB | Output is correct |
2 | Correct | 23 ms | 844 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 253 ms | 9972 KB | Output is correct |
2 | Correct | 25 ms | 880 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 405 ms | 17908 KB | Output is correct |
2 | Correct | 193 ms | 8520 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 619 ms | 28392 KB | Output is correct |
2 | Correct | 38 ms | 880 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1136 ms | 42928 KB | Output is correct |
2 | Correct | 542 ms | 21480 KB | Output is correct |