#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define f1 first
#define s2 second
#define pb push_back
#define mp make_pair
#define ll long long
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);
const int N=405;
int n,ans;
string s;
vector<string>str;
unordered_set<string>sety;
unordered_map<string,int>cnt;
int main(){
//fri("in.txt");
//fro("out.txt");
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n;
for(int i=0;i<n;i++){
cin>>s;
cnt[s]++;
str.pb(s);
//sety.insert(s);
}
for(int i=0;i<n;i++){
set<string>sety;
for(int j=0;j<str[i].length();j++){
for(int p=1;p+j<=str[i].length();p++){
string s1 (str[i],j,p);
if(sety.count(s1)){
continue;
}
sety.insert(s1);
if(cnt[s1]>1 && s1==str[i]){
ans+=cnt[s1]-1;
//cout<<s1<<" ";
}
else if(s1!=str[i]){
ans+=cnt[s1];
}
}
}
}
cout<<ans<<endl;
return 0;
}
Compilation message
lozinke.cpp: In function 'int main()':
lozinke.cpp:34:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<str[i].length();j++){
~^~~~~~~~~~~~~~~~
lozinke.cpp:35:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int p=1;p+j<=str[i].length();p++){
~~~^~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
10 ms |
760 KB |
Output is correct |
6 |
Correct |
16 ms |
760 KB |
Output is correct |
7 |
Correct |
22 ms |
1528 KB |
Output is correct |
8 |
Correct |
33 ms |
2168 KB |
Output is correct |
9 |
Correct |
79 ms |
2416 KB |
Output is correct |
10 |
Correct |
174 ms |
7232 KB |
Output is correct |
11 |
Correct |
131 ms |
4080 KB |
Output is correct |
12 |
Correct |
363 ms |
15208 KB |
Output is correct |
13 |
Correct |
228 ms |
2800 KB |
Output is correct |
14 |
Correct |
251 ms |
13988 KB |
Output is correct |
15 |
Correct |
371 ms |
15256 KB |
Output is correct |
16 |
Correct |
257 ms |
1852 KB |
Output is correct |
17 |
Correct |
76 ms |
1780 KB |
Output is correct |
18 |
Correct |
57 ms |
1652 KB |
Output is correct |
19 |
Correct |
247 ms |
8052 KB |
Output is correct |
20 |
Correct |
130 ms |
1728 KB |
Output is correct |