#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
int n,ans;
string password[20005];
//map<string,bool>idk;
map<string,map<string,bool>>idk;
void get_subs(string s)
{
string x;
for(int i=0;i<s.size();i++)
{
x+=s[i];
idk[s][x]=1;
string y;
int j = i;
while(j>=0&&y.size()<s.size())
{
y=s[j]+y;
idk[s][y]=1;
j--;
}
}
}
void check(string a,string b)
{
if(idk[a][b])ans++;
}
main()
{
cin>>n;
for(int i=0;i<n;i++)cin>>password[i];
for(int i=0;i<n;i++)
{
get_subs(password[i]);
}
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if(j==i)continue;
check(password[i],password[j]);
check(password[j],password[i]);
}
}
cout<<ans<<endl;
}
Compilation message
lozinke.cpp: In function 'void get_subs(std::string)':
lozinke.cpp:14:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | for(int i=0;i<s.size();i++)
| ~^~~~~~~~~
lozinke.cpp: At global scope:
lozinke.cpp:34:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
34 | main()
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
844 KB |
Output is correct |
2 |
Correct |
3 ms |
972 KB |
Output is correct |
3 |
Correct |
10 ms |
1504 KB |
Output is correct |
4 |
Correct |
79 ms |
6284 KB |
Output is correct |
5 |
Correct |
673 ms |
47772 KB |
Output is correct |
6 |
Runtime error |
721 ms |
65540 KB |
Execution killed with signal 9 |
7 |
Runtime error |
854 ms |
65540 KB |
Execution killed with signal 9 |
8 |
Runtime error |
975 ms |
65540 KB |
Execution killed with signal 9 |
9 |
Execution timed out |
1018 ms |
65540 KB |
Time limit exceeded |
10 |
Runtime error |
953 ms |
65540 KB |
Execution killed with signal 9 |
11 |
Runtime error |
894 ms |
65540 KB |
Execution killed with signal 9 |
12 |
Runtime error |
856 ms |
65540 KB |
Execution killed with signal 9 |
13 |
Runtime error |
832 ms |
65540 KB |
Execution killed with signal 9 |
14 |
Runtime error |
648 ms |
65540 KB |
Execution killed with signal 9 |
15 |
Runtime error |
812 ms |
65540 KB |
Execution killed with signal 9 |
16 |
Execution timed out |
1095 ms |
17496 KB |
Time limit exceeded |
17 |
Execution timed out |
1069 ms |
972 KB |
Time limit exceeded |
18 |
Execution timed out |
1093 ms |
972 KB |
Time limit exceeded |
19 |
Runtime error |
902 ms |
65540 KB |
Execution killed with signal 9 |
20 |
Execution timed out |
1101 ms |
20548 KB |
Time limit exceeded |