# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
116825 | 2019-06-14T01:53:14 Z | Licht | Lozinke (COCI17_lozinke) | C++14 | 480 ms | 16608 KB |
#include <bits/stdc++.h> using namespace std; #define int long long #define vt vector #define pb push_back #define pob pop_back #define vi vt<int> #define vvi vt<vi> #define vii vt<ii> #define vvii vt<vii> typedef long long ll; #define For(i,a,b) for(int i = a; i < b; i++) #define foR(i,a,b) for(int i = a; i <= b; i++) #define roF(i,a,b) for(int i = a - 1; i >= b; i--) #define Rof(i,a,b) for(int i = a; i >= b; i--) vector<string> v; map<string,int> dx; map<string,bool> dc; bool cmp(string a, string b){ return a.size() < b.size(); } signed main (){ /* freopen(".inp","r",stdin); freopen(".out","w",stdout); */ int n, coun = 0; cin >> n; string t; For(i,0,n){ cin >> t; v.pb(t); } sort(v.begin(),v.end(),cmp); For(i,0,n){ // cout << v[i] << "\n"; dc.clear(); //nc For(j,0,v[i].size()){ string temp; For(k,j,v[i].size()){ temp += v[i][k]; if((!dc[temp]) && dx[temp]){ dc[temp] = true; coun+=dx[temp]; } } } coun+=dx[v[i]]; dx[v[i]]++; // cout << coun << "\n"; } cout << coun; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
5 | Correct | 12 ms | 768 KB | Output is correct |
6 | Correct | 19 ms | 696 KB | Output is correct |
7 | Correct | 26 ms | 1528 KB | Output is correct |
8 | Correct | 38 ms | 2424 KB | Output is correct |
9 | Correct | 108 ms | 2404 KB | Output is correct |
10 | Correct | 200 ms | 7504 KB | Output is correct |
11 | Correct | 213 ms | 4208 KB | Output is correct |
12 | Correct | 480 ms | 16608 KB | Output is correct |
13 | Correct | 302 ms | 2796 KB | Output is correct |
14 | Correct | 332 ms | 15004 KB | Output is correct |
15 | Correct | 461 ms | 16412 KB | Output is correct |
16 | Correct | 283 ms | 1528 KB | Output is correct |
17 | Correct | 81 ms | 1528 KB | Output is correct |
18 | Correct | 61 ms | 1528 KB | Output is correct |
19 | Correct | 313 ms | 8540 KB | Output is correct |
20 | Correct | 167 ms | 1528 KB | Output is correct |