Submission #523954

#TimeUsernameProblemLanguageResultExecution timeMemory
523954tube5429Parametriziran (COCI19_parametriziran)C++14
110 / 110
1136 ms42928 KiB
#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 (stderr)

parametriziran.cpp: In function 'void solve(std::istream&)':
parametriziran.cpp:13:13: warning: unused variable 'h' [-Wunused-variable]
   13 |         int h = 0, mask1 = 0;
      |             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...