#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;
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;
str.pb(s);
}
for(int i=0;i<n;i++){
if(cnt[str[i]]!=0){
ans+=cnt[str[i]];
continue;
}
for(int j=0;j<n;j++){
if(j!=i && str[j].length()>=str[i].length() && str[j].find(str[i])!=string::npos){
ans++;
cnt[str[i]]++;
}
}
}
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
380 KB |
Output is correct |
5 |
Correct |
17 ms |
504 KB |
Output is correct |
6 |
Correct |
46 ms |
504 KB |
Output is correct |
7 |
Correct |
61 ms |
524 KB |
Output is correct |
8 |
Correct |
42 ms |
504 KB |
Output is correct |
9 |
Correct |
952 ms |
1372 KB |
Output is correct |
10 |
Execution timed out |
1073 ms |
1380 KB |
Time limit exceeded |
11 |
Execution timed out |
1071 ms |
1156 KB |
Time limit exceeded |
12 |
Execution timed out |
1082 ms |
1412 KB |
Time limit exceeded |
13 |
Execution timed out |
1086 ms |
1520 KB |
Time limit exceeded |
14 |
Execution timed out |
1095 ms |
1524 KB |
Time limit exceeded |
15 |
Execution timed out |
1072 ms |
1524 KB |
Time limit exceeded |
16 |
Correct |
733 ms |
1528 KB |
Output is correct |
17 |
Correct |
6 ms |
1524 KB |
Output is correct |
18 |
Correct |
9 ms |
1524 KB |
Output is correct |
19 |
Execution timed out |
1066 ms |
1524 KB |
Time limit exceeded |
20 |
Correct |
506 ms |
1524 KB |
Output is correct |