Submission #97336

#TimeUsernameProblemLanguageResultExecution timeMemory
97336szawinisParametriziran (COCI19_parametriziran)C++17
88 / 110
3068 ms66560 KiB
#include <bits/stdc++.h> using namespace std; #define long long long const long MOD = 1e9+7, LINF = 1e18 + 1e16; const int INF = 1e9+1; const double EPS = 1e-10; const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1}; class TaskD { int n, m; map<int,int> ls[64][64]; long ans; public: void solve(istream &cin, ostream &cout) { 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]; 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; } }; class Solver { public: void solve(std::istream& in, std::ostream& out) { TaskD *obj = new TaskD(); obj->solve(in, out); delete obj; } }; int main() { ios::sync_with_stdio(false); cin.tie(0); Solver solver; std::istream& in(std::cin); std::ostream& out(std::cout); solver.solve(in, out); return 0; }

Compilation message (stderr)

parametriziran.cpp: In member function 'void TaskD::solve(std::istream&, std::ostream&)':
parametriziran.cpp:19:17: warning: unused variable 'h' [-Wunused-variable]
             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...