# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
491151 | 2021-11-30T16:14:17 Z | Yazan_Alattar | Parametriziran (COCI19_parametriziran) | C++14 | 1223 ms | 42964 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; } // different mask2 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 | 460 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 460 KB | Output is correct |
2 | Correct | 7 ms | 460 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 540 KB | Output is correct |
2 | Correct | 16 ms | 540 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 1176 KB | Output is correct |
2 | Correct | 18 ms | 716 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 41 ms | 912 KB | Output is correct |
2 | Correct | 43 ms | 1432 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 165 ms | 5360 KB | Output is correct |
2 | Correct | 22 ms | 588 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 315 ms | 9924 KB | Output is correct |
2 | Correct | 27 ms | 716 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 450 ms | 17760 KB | Output is correct |
2 | Correct | 233 ms | 8244 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 644 ms | 28176 KB | Output is correct |
2 | Correct | 39 ms | 664 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1223 ms | 42964 KB | Output is correct |
2 | Correct | 629 ms | 21472 KB | Output is correct |