# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
730942 | 2023-04-26T16:33:23 Z | TheSahib | Lozinke (COCI17_lozinke) | C++14 | 235 ms | 13644 KB |
#include <bits/stdc++.h> #define ll long long #define pii pair<int, int> const int oo = int(1e9) + 9; using namespace std; int n; string arr[20006]; ll hashs[20006]; map<ll, int> mp; int main(){ cin >> n; for (int i = 0; i < n; ++i) { string s; cin >> s; arr[i] = s; set<ll> st; for (int j = 0; j < s.size(); ++j) { ll h = 0; for (int k = j; k < s.size(); k++) { h = (h * 26) + s[k] - 'a' + 1; st.insert(h); if(j == 0 && k == s.size() - 1){ hashs[i] = h; } } } for(auto& a:st){ mp[a]++; } } ll ans = 0; for (int i = 0; i < n; i++) { ans += mp[hashs[i]] - 1; } cout << ans << '\n'; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 852 KB | Output is correct |
2 | Correct | 1 ms | 852 KB | Output is correct |
3 | Correct | 1 ms | 940 KB | Output is correct |
4 | Correct | 2 ms | 980 KB | Output is correct |
5 | Correct | 5 ms | 1236 KB | Output is correct |
6 | Correct | 7 ms | 1192 KB | Output is correct |
7 | Correct | 10 ms | 1720 KB | Output is correct |
8 | Correct | 17 ms | 2388 KB | Output is correct |
9 | Correct | 37 ms | 2460 KB | Output is correct |
10 | Correct | 94 ms | 6440 KB | Output is correct |
11 | Correct | 61 ms | 3812 KB | Output is correct |
12 | Correct | 214 ms | 13644 KB | Output is correct |
13 | Correct | 108 ms | 2556 KB | Output is correct |
14 | Correct | 161 ms | 12252 KB | Output is correct |
15 | Correct | 235 ms | 13516 KB | Output is correct |
16 | Correct | 98 ms | 1300 KB | Output is correct |
17 | Correct | 23 ms | 1212 KB | Output is correct |
18 | Correct | 19 ms | 1248 KB | Output is correct |
19 | Correct | 137 ms | 7328 KB | Output is correct |
20 | Correct | 49 ms | 1364 KB | Output is correct |