# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
116818 | 2019-06-14T01:45:58 Z | tuanasanh | Lozinke (COCI17_lozinke) | C++17 | 562 ms | 16488 KB |
#include <bits/stdc++.h> #pragma O3 using namespace std; long long n,ans=0LL; vector<string> r; string s; map<string,int> mp; bool cmp(string &a,string &b){ return a.length()<b.length(); } int main(){ cin>>n; for(int i=0;i<n;i++){ cin>>s; r.push_back(s); } sort(r.begin(),r.end(),cmp); for(int i=0;i<n;i++){ s=r[i]; ans+=mp[s]; map<string,int> mp2; for(int j=0;j<s.length();j++){ string tmp=""; for(int k=j;k<s.length();k++){ tmp+=s[k]; if(mp2[tmp]==0) ans+=mp[tmp]; mp2[tmp]++; } } mp[s]++; } cout<<ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 252 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 11 ms | 768 KB | Output is correct |
6 | Correct | 18 ms | 760 KB | Output is correct |
7 | Correct | 25 ms | 1528 KB | Output is correct |
8 | Correct | 40 ms | 2268 KB | Output is correct |
9 | Correct | 91 ms | 2416 KB | Output is correct |
10 | Correct | 219 ms | 7536 KB | Output is correct |
11 | Correct | 162 ms | 4212 KB | Output is correct |
12 | Correct | 562 ms | 16488 KB | Output is correct |
13 | Correct | 296 ms | 2664 KB | Output is correct |
14 | Correct | 323 ms | 15028 KB | Output is correct |
15 | Correct | 513 ms | 16360 KB | Output is correct |
16 | Correct | 321 ms | 1528 KB | Output is correct |
17 | Correct | 81 ms | 1528 KB | Output is correct |
18 | Correct | 59 ms | 1528 KB | Output is correct |
19 | Correct | 322 ms | 8656 KB | Output is correct |
20 | Correct | 135 ms | 1528 KB | Output is correct |