#include<bits/stdc++.h>
using namespace std;
#define ll vector<long long, long long>
#define fi first
#define se second
const int maxn = 2e4 + 10;
const int mod = 1e9 + 7;
const int inf = 1e9;
long long n,m,p,ans,l[maxn];
string a,b,s[maxn];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
//freopen("PASS.INP","r",stdin);
//freopen("PASS.OUT","w",stdout);
cin>>n;
for (int i=1; i<=n; i++) cin>>s[i],l[i]=s[i].size();
for (int i=1; i<=n-1; i++)
for (int j=i+1; j<=n; j++)
{
a=s[i]; b=s[j]; p=l[i]; m=l[j];
if (p==m)
{
if (a==b) ans+=2;
continue;
}
if (p>m)
{
swap(a,b); swap(p,m);
}
b+=a;
if (b.find(a)!=m) ans++;
}
cout<<ans;
}
Compilation message
lozinke.cpp: In function 'int main()':
lozinke.cpp:32:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
32 | if (b.find(a)!=m) ans++;
| ~~~~~~~~~^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
856 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
860 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
860 KB |
Output isn't correct |
4 |
Incorrect |
5 ms |
860 KB |
Output isn't correct |
5 |
Incorrect |
25 ms |
1112 KB |
Output isn't correct |
6 |
Incorrect |
66 ms |
856 KB |
Output isn't correct |
7 |
Incorrect |
92 ms |
1116 KB |
Output isn't correct |
8 |
Correct |
74 ms |
1112 KB |
Output is correct |
9 |
Execution timed out |
1038 ms |
1124 KB |
Time limit exceeded |
10 |
Execution timed out |
1063 ms |
1116 KB |
Time limit exceeded |
11 |
Execution timed out |
1010 ms |
1112 KB |
Time limit exceeded |
12 |
Execution timed out |
1051 ms |
1112 KB |
Time limit exceeded |
13 |
Execution timed out |
1031 ms |
1368 KB |
Time limit exceeded |
14 |
Execution timed out |
1068 ms |
1116 KB |
Time limit exceeded |
15 |
Execution timed out |
1054 ms |
1372 KB |
Time limit exceeded |
16 |
Execution timed out |
1048 ms |
1372 KB |
Time limit exceeded |
17 |
Execution timed out |
1064 ms |
1372 KB |
Time limit exceeded |
18 |
Execution timed out |
1018 ms |
1368 KB |
Time limit exceeded |
19 |
Execution timed out |
1036 ms |
1372 KB |
Time limit exceeded |
20 |
Execution timed out |
1042 ms |
1624 KB |
Time limit exceeded |