# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
138100 | Linca_Robert | Lozinke (COCI17_lozinke) | C++14 | 1077 ms | 2904 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
int N, ans;
string arr[20005], str;
multiset<string> S;
vector<string> aux;
inline bool cmp( const string &a, const string &b ){
if( a.size() == b.size() )
return a < b;
return a.size() < b.size();
}
int main(){
cin >> N;
for( int i = 1; i <= N; i++ )
cin >> arr[i];
sort( arr + 1, arr + N + 1, cmp );
aux.resize( 115 );
for( int i = 1; i <= N; i++ ){
aux.clear();
for( int p1 = 0; p1 < arr[i].length(); p1++ ){
str.clear();
for( int p2 = p1; p2 < arr[i].length(); p2++ ){
str.push_back( arr[i][p2] );
aux.push_back( str );
}
}
sort( aux.begin(), aux.end() );
aux.resize( distance( aux.begin(), unique( aux.begin(), aux.end() ) ) );
for( int p = 0; p < aux.size(); p++ )
ans += S.count( aux[p] );
S.insert( arr[i] );
}
int nr = 1;
for( int i = 2; i <= N; i++ ){
if( arr[i] == arr[i - 1] )
nr++;
else
nr = 1;
ans += nr - 1;
}
cout << ans << "\n";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |