# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
867065 | 2023-10-27T16:09:18 Z | HoriaHaivas | Parametriziran (COCI19_parametriziran) | C++14 | 419 ms | 5724 KB |
/* "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 << " " #warning ai grija la ? ca l ai transformat in { #pragma GCC optimize("Ofast") using namespace std; const int mod=666.013; const int base=29; string s[50001]; unordered_map<int,int> hashcount[(1<<7)]; 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; bool ok; cin >> n >> m; for (j=1; j<=n; j++) { cin >> s[j]; for (i=0; i<s[j].size(); i++) { if (s[j][i]=='?') s[j][i]='{';///urmatorul caracter dupa z } for (mask=1; mask<(1<<(m+1)); mask++) { hashbuild=0; for (i=0; i<s[j].size(); i++) { if (mask&(1<<i)) hashbuild=((hashbuild*base)%mod+(s[j][i]-'a'+1))%mod; } hashcount[mask][hashbuild]++; } } ans=0; for (j=1; j<=n; j++) { mask=0; for (i=0; i<s[j].size(); i++) { if (s[j][i]!='{') { mask=mask|(1<<i); } } if (mask!=0) { for (mask2=0; mask2<=mask; mask2++) { ok=true; for (i=0; i<s[j].size() && ok; i++) { if ((mask2&(1<<i)) && !(mask&(1<<i))) ok=false; } if (ok) { hashbuild=0; for (i=0; i<s[j].size(); i++) { if (mask&(1<<i)) { if (mask2&(1<<i)) hashbuild=((hashbuild*base)%mod+('{'-'a'+1))%mod; else hashbuild=((hashbuild*base)%mod+(s[j][i]-'a'+1))%mod; } } ans+=hashcount[mask][hashbuild]; } } } else { ans+=n; } } cout << (ans-n)/2; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 1884 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 1884 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 1884 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 17 ms | 2140 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 23 ms | 2136 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 62 ms | 2648 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 105 ms | 3420 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 154 ms | 3552 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 285 ms | 5612 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 419 ms | 5724 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |