# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
867144 | 2023-10-27T18:40:24 Z | HoriaHaivas | Parametriziran (COCI19_parametriziran) | C++14 | 1133 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; struct custom_hash { static uint64_t splitmix64(uint64_t x) { // http://xorshift.di.unimi.it/splitmix64.c x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } }; const int mod=1e9+9; const int base=29; string s[50001]; unordered_map<int,int,custom_hash> 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; 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)); 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 | 7 ms | 1884 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 2048 KB | Output is correct |
2 | Correct | 7 ms | 2152 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 2140 KB | Output is correct |
2 | Correct | 14 ms | 2140 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 2652 KB | Output is correct |
2 | Correct | 16 ms | 2300 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 2556 KB | Output is correct |
2 | Correct | 29 ms | 3336 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 121 ms | 8132 KB | Output is correct |
2 | Correct | 32 ms | 2764 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 222 ms | 17524 KB | Output is correct |
2 | Correct | 52 ms | 3412 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 482 ms | 31856 KB | Output is correct |
2 | Correct | 196 ms | 16304 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1090 ms | 60664 KB | Output is correct |
2 | Correct | 138 ms | 4876 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1133 ms | 65536 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |