Submission #334573

#TimeUsernameProblemLanguageResultExecution timeMemory
334573dooweyParametriziran (COCI19_parametriziran)C++14
0 / 110
224 ms15212 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define fi first #define se second #define mp make_pair #define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); const int M = 6; const int AL = 27; const int N = 50005; vector<int> ind[1<<M]; int f[M]; string s[N]; int vl[N][1<<M]; int main(){ fastIO; int n, m; cin >> n >> m; f[0]=1; for(int i = 1; i < M ; i ++) { f[i]=(f[i-1]*AL); } int que; int sln; for(int i = 0 ; i < n; i ++ ){ cin >> s[i]; que = 0; for(int j = 0 ; j < m ; j ++ ){ if(s[i][j] == '?') que |= (1 << j); } ind[que].push_back(i); for(int mm = 0 ; mm < (1 << m); mm ++ ){ if((mm & que) != que) continue; sln = 0; for(int j = 0 ; j < m ; j ++ ){ if((mm & (1 << j))) continue; sln += f[j] * 1ll * (s[i][j] - 'a' + 1); } vl[i][mm]=sln; } } ll soln = 0; vector<int> ay, by; int mask; int jj,c1,c2; for(int p = 0 ; p < (1 << m); p ++ ){ for(int q = p + 1 ; q < (1 << m) ; q ++ ){ if(ind[p].empty() || ind[q].empty()) continue; mask = (p | q); ay.clear(); by.clear(); for(auto x : ind[p]){ ay.push_back(vl[x][mask]); } for(auto x : ind[q]){ by.push_back(vl[x][mask]); } sort(ay.begin(), ay.end()); sort(by.begin(), by.end()); jj = 0; c1 = 0; for(int i = 0 ; i < ay.size(); i ++ ){ c1 ++ ; if(i + 1 == ay.size() || ay[i] != ay[i + 1]){ c2 = 0; while(jj < by.size() && by[jj] <= ay[i]){ if(by[jj] == ay[i]){ c2 ++ ; } jj ++ ; } soln += c1 * 1ll * c2; c1 = 0; } } } } cout << soln << "\n"; return 0; }

Compilation message (stderr)

parametriziran.cpp: In function 'int main()':
parametriziran.cpp:70:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |             for(int i = 0 ; i < ay.size(); i ++ ){
      |                             ~~^~~~~~~~~~~
parametriziran.cpp:72:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |                 if(i + 1 == ay.size() || ay[i] != ay[i + 1]){
      |                    ~~~~~~^~~~~~~~~~~~
parametriziran.cpp:74:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |                     while(jj < by.size() && by[jj] <= ay[i]){
      |                           ~~~^~~~~~~~~~~
#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...