# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
472793 | 2021-09-14T10:41:39 Z | AbdoMo | Lozinke (COCI17_lozinke) | C++17 | 1000 ms | 3400 KB |
#include<bits/stdc++.h> #define int long long #define ll long long #define pb push_back const int mod = 1e9+7; using namespace std; bool comp(string a,string b) { if(a.size()==b.size()) { return a<b; } return a.size()<b.size(); } void solve(){ int n; cin>>n; vector<string>v; map<string,int>freq; set<string,decltype(comp)*>st(comp); for(int i=0;i<n;i++) { string s; cin>>s; st.insert(s); freq[s]++; v.pb(s); } sort(v.begin(),v.end(),comp); int ans=0; int c=1; auto it=st.begin(); for(int i=0;i<n;i+=freq[v[i]],it++) { auto j=it; j++; ans+=freq[v[i]]*(freq[v[i]]-1); for(;j!=st.end();j++) { string x=*j; if(x.find(v[i])!=-1) { ans+=freq[*j]*freq[v[i]]; } } } cout<<ans<<endl; /* */ } int32_t main(){ int t=1; ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); //cin>>t; while(t--){solve();} return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 3 ms | 332 KB | Output is correct |
5 | Correct | 19 ms | 472 KB | Output is correct |
6 | Correct | 52 ms | 460 KB | Output is correct |
7 | Correct | 70 ms | 588 KB | Output is correct |
8 | Correct | 42 ms | 460 KB | Output is correct |
9 | Correct | 960 ms | 1592 KB | Output is correct |
10 | Execution timed out | 1087 ms | 1736 KB | Time limit exceeded |
11 | Execution timed out | 1094 ms | 2164 KB | Time limit exceeded |
12 | Execution timed out | 1085 ms | 2328 KB | Time limit exceeded |
13 | Execution timed out | 1092 ms | 3040 KB | Time limit exceeded |
14 | Execution timed out | 1091 ms | 3400 KB | Time limit exceeded |
15 | Execution timed out | 1069 ms | 3140 KB | Time limit exceeded |
16 | Correct | 78 ms | 1476 KB | Output is correct |
17 | Correct | 12 ms | 1484 KB | Output is correct |
18 | Correct | 15 ms | 1484 KB | Output is correct |
19 | Execution timed out | 1092 ms | 2956 KB | Time limit exceeded |
20 | Correct | 114 ms | 1604 KB | Output is correct |