# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
867108 | 2023-10-27T16:59:20 Z | HoriaHaivas | Parametriziran (COCI19_parametriziran) | C++14 | 994 ms | 65536 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=1e9+9; const int base=29; unordered_map<int,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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 348 KB | Output is correct |
2 | Correct | 4 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 348 KB | Output is correct |
2 | Correct | 8 ms | 488 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 1144 KB | Output is correct |
2 | Correct | 8 ms | 600 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 1112 KB | Output is correct |
2 | Correct | 18 ms | 1856 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 78 ms | 6268 KB | Output is correct |
2 | Correct | 21 ms | 1304 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 191 ms | 15708 KB | Output is correct |
2 | Correct | 35 ms | 1804 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 386 ms | 30000 KB | Output is correct |
2 | Correct | 142 ms | 14132 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 958 ms | 57208 KB | Output is correct |
2 | Correct | 92 ms | 3160 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 994 ms | 65536 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |