# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
444209 | 2021-07-13T11:07:36 Z | BeanZ | Lozinke (COCI17_lozinke) | C++14 | 326 ms | 15968 KB |
// I_Love_LPL 1y0m3d #include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' const int N = 1e5 + 5; long long mod = 100000000861; const int lim = 4e5 + 5; const int lg = 20; const int base = 37; const long double eps = 1e-6; string s[N]; ll h[N], p[N]; map<ll, ll> mem; ll get(ll l, ll r){ return (h[r] - h[l - 1] * p[r - l + 1] + mod * mod) % mod; } bool cmp(string x, string y){ return x.length() < y.length(); } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("tests.inp", "r")){ freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } ll n; cin >> n; for (int i = 1; i <= n; i++){ cin >> s[i]; } sort(s + 1, s + n + 1, cmp); p[0] = 1; ll ans = 0; for (int i = 1; i <= 10; i++) p[i] = p[i - 1] * base % mod; for (int i = 1; i <= n; i++){ ll x = s[i].length(); for (int j = 1; j <= x; j++){ h[j] = (h[j - 1] * base + (s[i][j - 1] - 'a' + 1)) % mod; } map<ll, ll> eat; for (int j = 1; j <= x; j++){ for (int k = j; k <= x; k++){ if (j == 1 && k == x) continue; if (!eat[get(j, k)]) ans = ans + mem[get(j, k)]; eat[get(j, k)] = 1; } } mem[h[x]]++; } for (auto j : mem){ ans = ans + j.second * (j.second - 1); } cout << ans; } /* Ans: Out: */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 3404 KB | Output isn't correct |
2 | Incorrect | 2 ms | 3340 KB | Output isn't correct |
3 | Incorrect | 2 ms | 3404 KB | Output isn't correct |
4 | Incorrect | 3 ms | 3404 KB | Output isn't correct |
5 | Incorrect | 8 ms | 3776 KB | Output isn't correct |
6 | Incorrect | 12 ms | 3664 KB | Output isn't correct |
7 | Incorrect | 14 ms | 4276 KB | Output isn't correct |
8 | Correct | 25 ms | 4932 KB | Output is correct |
9 | Incorrect | 50 ms | 4920 KB | Output isn't correct |
10 | Incorrect | 116 ms | 8984 KB | Output isn't correct |
11 | Incorrect | 82 ms | 6396 KB | Output isn't correct |
12 | Correct | 287 ms | 15968 KB | Output is correct |
13 | Incorrect | 138 ms | 5188 KB | Output isn't correct |
14 | Incorrect | 200 ms | 14724 KB | Output isn't correct |
15 | Incorrect | 326 ms | 15684 KB | Output isn't correct |
16 | Incorrect | 142 ms | 3524 KB | Output isn't correct |
17 | Correct | 37 ms | 3404 KB | Output is correct |
18 | Incorrect | 31 ms | 3432 KB | Output isn't correct |
19 | Incorrect | 166 ms | 9660 KB | Output isn't correct |
20 | Incorrect | 69 ms | 3568 KB | Output isn't correct |