Submission #867114

#TimeUsernameProblemLanguageResultExecution timeMemory
867114HoriaHaivasParametriziran (COCI19_parametriziran)C++14
99 / 110
997 ms65536 KiB
/* "care a facut teste cu Lattice reduction attack e ciudat" "linistiti va putin" - 2023 - */ #include<bits/stdc++.h> #define debug(x) cerr << #x << " " << x << "\n" #define debugs(x) cerr << #x << " " << x << " " #pragma GCC optimize("Ofast") using namespace std; const int mod=1e9+9; const int base=29; unordered_map<int,unsigned short int> hashcount[(1<<6)]; int main() { ifstream fin(".in"); ofstream fout(".out"); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int i,j,n,m,ans,mask,hashbuild,mask2; string s; bool ok; cin >> n >> m; ans=0; for (j=1; j<=n; j++) { cin >> s; for (i=0; i<s.size(); i++) { if (s[i]=='?') s[i]='{';///urmatorul caracter dupa z } for (mask=1; mask<(1<<(m)); mask++) { hashbuild=0; for (i=0; i<s.size(); i++) { if (mask&(1<<i)) hashbuild=((hashbuild*base)%mod+(s[i]-'a'+1))%mod; } hashcount[mask][hashbuild]++; } mask=0; for (i=0; i<s.size(); i++) { if (s[i]!='{') { mask=mask|(1<<i); } } if (mask!=0) { for (mask2=0; mask2<=mask; mask2++) { ok=true; for (i=0; i<s.size() && ok; i++) { if ((mask2&(1<<i)) && !(mask&(1<<i))) ok=false; } if (ok) { hashbuild=0; for (i=0; i<s.size(); i++) { if (mask&(1<<i)) { if (mask2&(1<<i)) hashbuild=((hashbuild*base)%mod+('{'-'a'+1))%mod; else hashbuild=((hashbuild*base)%mod+(s[i]-'a'+1))%mod; } } ans+=hashcount[mask][hashbuild]; } } } else { ans+=j; } } cout << ans-n; return 0; }

Compilation message (stderr)

parametriziran.cpp: In function 'int main()':
parametriziran.cpp:33:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for (i=0; i<s.size(); i++)
      |                   ~^~~~~~~~~
parametriziran.cpp:41:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |             for (i=0; i<s.size(); i++)
      |                       ~^~~~~~~~~
parametriziran.cpp:49:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         for (i=0; i<s.size(); i++)
      |                   ~^~~~~~~~~
parametriziran.cpp:61:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |                 for (i=0; i<s.size() && ok; i++)
      |                           ~^~~~~~~~~
parametriziran.cpp:69:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |                     for (i=0; i<s.size(); 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...