#include <bits/stdc++.h>
using namespace std;
bool cmp(string a,string b)
{
if(a.size()<b.size())return true;
return false;
}
int n;
string s[20009];
map<string,bool>m[20009];
int main()
{
cin>>n;
for(int i=0;i<n;i++)cin>>s[i];
sort(s,s+n,cmp);
int ans=0;
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
for(int k=0;k<s[j].size()-s[i].size()+1;k++)
{
if(s[j].substr(k,s[i].size())==s[i])
{
ans++;
//cout<<i<<" "<<j<<"\n";
break;
}
}
if(s[i]==s[j])ans++;//,cout<<j<<" "<<i<<"\n";
}
}
cout<<ans;
}
Compilation message
lozinke.cpp: In function 'int main()':
lozinke.cpp:22:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int k=0;k<s[j].size()-s[i].size()+1;k++)
~^~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1912 KB |
Output is correct |
2 |
Correct |
3 ms |
1912 KB |
Output is correct |
3 |
Correct |
4 ms |
1912 KB |
Output is correct |
4 |
Correct |
9 ms |
1912 KB |
Output is correct |
5 |
Correct |
45 ms |
1912 KB |
Output is correct |
6 |
Correct |
97 ms |
1912 KB |
Output is correct |
7 |
Correct |
161 ms |
2012 KB |
Output is correct |
8 |
Correct |
117 ms |
1928 KB |
Output is correct |
9 |
Execution timed out |
1085 ms |
1912 KB |
Time limit exceeded |
10 |
Execution timed out |
1085 ms |
1912 KB |
Time limit exceeded |
11 |
Execution timed out |
1061 ms |
1912 KB |
Time limit exceeded |
12 |
Execution timed out |
1076 ms |
1912 KB |
Time limit exceeded |
13 |
Execution timed out |
1062 ms |
1912 KB |
Time limit exceeded |
14 |
Execution timed out |
1070 ms |
1912 KB |
Time limit exceeded |
15 |
Execution timed out |
1086 ms |
1912 KB |
Time limit exceeded |
16 |
Execution timed out |
1045 ms |
1912 KB |
Time limit exceeded |
17 |
Execution timed out |
1045 ms |
1912 KB |
Time limit exceeded |
18 |
Execution timed out |
1038 ms |
1912 KB |
Time limit exceeded |
19 |
Execution timed out |
1081 ms |
1912 KB |
Time limit exceeded |
20 |
Execution timed out |
1081 ms |
1912 KB |
Time limit exceeded |