# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
94560 | 2019-01-20T17:37:20 Z | thebes | Lozinke (COCI17_lozinke) | C++14 | 243 ms | 16184 KB |
#include <bits/stdc++.h> using namespace std; const int MN = 2e4+5; string s[MN]; unordered_map<string,int> mp, w; unordered_set<string> st; int n, i, ans, j, k; int main(){ for(scanf("%d",&n),i=1;i<=n;i++) cin >> s[i]; sort(s+1,s+n+1,[](string i,string j){return i.size()>j.size();}); for(i=1;i<=n;i++){ ans += mp[s[i]]+w[s[i]]; st.clear(); w[s[i]]++; for(j=0;j<s[i].size();j++){ string sub = ""; for(k=j;k<s[i].size();k++){ sub += s[i][k]; if(!st.count(sub)){ st.insert(sub); mp[sub]++; } } } } printf("%d\n",ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 892 KB | Output is correct |
2 | Correct | 2 ms | 1016 KB | Output is correct |
3 | Correct | 3 ms | 1016 KB | Output is correct |
4 | Correct | 3 ms | 1016 KB | Output is correct |
5 | Correct | 7 ms | 1400 KB | Output is correct |
6 | Correct | 10 ms | 1400 KB | Output is correct |
7 | Correct | 13 ms | 2168 KB | Output is correct |
8 | Correct | 20 ms | 2808 KB | Output is correct |
9 | Correct | 50 ms | 3092 KB | Output is correct |
10 | Correct | 98 ms | 7944 KB | Output is correct |
11 | Correct | 72 ms | 4900 KB | Output is correct |
12 | Correct | 243 ms | 16056 KB | Output is correct |
13 | Correct | 120 ms | 4004 KB | Output is correct |
14 | Correct | 161 ms | 15160 KB | Output is correct |
15 | Correct | 201 ms | 16184 KB | Output is correct |
16 | Correct | 125 ms | 1404 KB | Output is correct |
17 | Correct | 73 ms | 1144 KB | Output is correct |
18 | Correct | 56 ms | 1144 KB | Output is correct |
19 | Correct | 141 ms | 8984 KB | Output is correct |
20 | Correct | 172 ms | 1400 KB | Output is correct |