# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
67363 | 2018-08-14T06:59:16 Z | win11905 | Lozinke (COCI17_lozinke) | C++11 | 553 ms | 14456 KB |
#include <bits/stdc++.h> using namespace std; #define pii pair<int, int> #define x first #define y second const int N = 2e4+5; int n; char A[N][15]; pii add(pii a, pii b) { return pii(a.x + b.x, a.y + b.y); } pii mul(pii a, pii b) { return pii(a.x * b.x, a.y * b.y); } pii iden(131, 133); pii ret[N]; map<pii, int> M; int main() { scanf("%d", &n); for(int z = 1; z <= n; ++z) { scanf("%s", A[z]+1); int len = strlen(A[z]+1); set<pii> S; pii hash; for(int i = 1; i <= len; ++i) for(int j = i; j <= len; ++j) { if(i == j) hash = pii(0, 0); hash = add(mul(hash, iden), pii(A[z][j], A[z][j])); S.emplace(hash); if(i == 1 && j == len) ret[z] = hash; } for(auto x : S) M[x]++; } int sum = -n; for(int i = 1; i <= n; ++i) sum += M[ret[i]]; return !printf("%d\n", sum); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 3 ms | 380 KB | Output is correct |
3 | Correct | 3 ms | 608 KB | Output is correct |
4 | Correct | 4 ms | 608 KB | Output is correct |
5 | Correct | 8 ms | 972 KB | Output is correct |
6 | Correct | 18 ms | 1024 KB | Output is correct |
7 | Correct | 20 ms | 1564 KB | Output is correct |
8 | Correct | 35 ms | 2312 KB | Output is correct |
9 | Correct | 68 ms | 2604 KB | Output is correct |
10 | Correct | 172 ms | 6612 KB | Output is correct |
11 | Correct | 128 ms | 6612 KB | Output is correct |
12 | Correct | 553 ms | 14188 KB | Output is correct |
13 | Correct | 193 ms | 14188 KB | Output is correct |
14 | Correct | 370 ms | 14188 KB | Output is correct |
15 | Correct | 504 ms | 14456 KB | Output is correct |
16 | Correct | 187 ms | 14456 KB | Output is correct |
17 | Correct | 69 ms | 14456 KB | Output is correct |
18 | Correct | 46 ms | 14456 KB | Output is correct |
19 | Correct | 247 ms | 14456 KB | Output is correct |
20 | Correct | 77 ms | 14456 KB | Output is correct |