#include <bits/stdc++.h>
using namespace std;
#define fi ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//#define ll double
#define ll long long
#define F first
#define S second
#define sz size()
#define all(s) s.begin(),s.end()
#define all1(s) s.rbegin(),s.rend()
int main()
{
// freopen("maxcross.in","r",stdin);freopen("maxcross.out","w",stdout);
ll T=1;
//cin>>T;ll oo=0;
while(T--)
{
ll n;
cin>>n;
pair<ll,string>a[n];
for(ll i=0;i<n;i++){
cin>>a[i].second;
a[i].first=a[i].second.size();
}
sort(a,a+n);ll c=0;
for(ll i=0;i<n;i++){
for(ll j=0;j<n;j++){if(a[j].first<a[i].first||i==j)continue;
string x="";
for(ll e=0;e<a[j].first;e++){
if(x.size()>=a[i].first){
reverse(all(x));
x.pop_back();
reverse(all(x));
}x+=a[j].second[e];//cout<<x<<" ";
if(x==a[i].second){
c++;//cout<<i<<" "<<j<<" "<<x<<" "<<a[i].second<<" "<<a[j].second;
break;
}
}//cout<<"\n";
}
}cout<<c;
}
}
Compilation message
lozinke.cpp: In function 'int main()':
lozinke.cpp:33:32: 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]
33 | if(x.size()>=a[i].first){
| ~~~~~~~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
6 ms |
348 KB |
Output is correct |
5 |
Correct |
45 ms |
464 KB |
Output is correct |
6 |
Correct |
115 ms |
464 KB |
Output is correct |
7 |
Correct |
166 ms |
484 KB |
Output is correct |
8 |
Correct |
200 ms |
348 KB |
Output is correct |
9 |
Execution timed out |
1059 ms |
600 KB |
Time limit exceeded |
10 |
Execution timed out |
1035 ms |
600 KB |
Time limit exceeded |
11 |
Execution timed out |
1037 ms |
860 KB |
Time limit exceeded |
12 |
Execution timed out |
1099 ms |
860 KB |
Time limit exceeded |
13 |
Execution timed out |
1069 ms |
1116 KB |
Time limit exceeded |
14 |
Execution timed out |
1030 ms |
1112 KB |
Time limit exceeded |
15 |
Execution timed out |
1024 ms |
1112 KB |
Time limit exceeded |
16 |
Execution timed out |
1002 ms |
1112 KB |
Time limit exceeded |
17 |
Execution timed out |
1075 ms |
1116 KB |
Time limit exceeded |
18 |
Execution timed out |
1066 ms |
1116 KB |
Time limit exceeded |
19 |
Execution timed out |
1026 ms |
1116 KB |
Time limit exceeded |
20 |
Execution timed out |
1047 ms |
1112 KB |
Time limit exceeded |