# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
280465 | 2020-08-22T19:43:02 Z | Revo7 | Lozinke (COCI17_lozinke) | C++14 | 272 ms | 15692 KB |
#include <bits/stdc++.h> #define ll long long #define pb push_back #define left 2*i+1 #define righ 2*i+2 #define mid (l+r)/2 #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; const ll maxn=2e4+100; const ll mod=1e9+9; const ll base=27; ll n; string s[maxn]; unordered_map<string,ll>cnt; ll ans=0; unordered_map<string,bool>vis; void solve(ll i){ vis.clear(); for(ll l=0;l<s[i].size();l++){ string t=""; for(ll r=l;r<s[i].size();r++){ t.pb(s[i][r]); if(!vis[t]){ ans+=cnt[t]; vis[t]=1; } } } ans--; } int main() { //setIO("threesum"); IOS cin>>n; for(ll i=0;i<n;i++)cin>>s[i]; for(ll i=0;i<n;i++){ cnt[s[i]]++; } for(ll i=0;i<n;i++)solve(i); cout<<ans<<endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1024 KB | Output is correct |
2 | Correct | 1 ms | 1024 KB | Output is correct |
3 | Correct | 1 ms | 1024 KB | Output is correct |
4 | Correct | 2 ms | 1024 KB | Output is correct |
5 | Correct | 6 ms | 1280 KB | Output is correct |
6 | Correct | 9 ms | 1280 KB | Output is correct |
7 | Correct | 11 ms | 1920 KB | Output is correct |
8 | Correct | 18 ms | 2816 KB | Output is correct |
9 | Correct | 46 ms | 2684 KB | Output is correct |
10 | Correct | 96 ms | 7496 KB | Output is correct |
11 | Correct | 72 ms | 4376 KB | Output is correct |
12 | Correct | 246 ms | 15692 KB | Output is correct |
13 | Correct | 129 ms | 2808 KB | Output is correct |
14 | Correct | 175 ms | 14268 KB | Output is correct |
15 | Correct | 272 ms | 15420 KB | Output is correct |
16 | Correct | 146 ms | 1388 KB | Output is correct |
17 | Correct | 75 ms | 1152 KB | Output is correct |
18 | Correct | 53 ms | 1152 KB | Output is correct |
19 | Correct | 157 ms | 8216 KB | Output is correct |
20 | Correct | 73 ms | 1400 KB | Output is correct |