Submission #138100

#TimeUsernameProblemLanguageResultExecution timeMemory
138100Linca_RobertLozinke (COCI17_lozinke)C++14
90 / 100
1077 ms2904 KiB
#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)

lozinke.cpp: In function 'int main()':
lozinke.cpp:26:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for( int p1 = 0; p1 < arr[i].length(); p1++ ){
                          ~~~^~~~~~~~~~~~~~~~~
lozinke.cpp:28:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for( int p2 = p1; p2 < arr[i].length(); p2++ ){
                               ~~~^~~~~~~~~~~~~~~~~
lozinke.cpp:37:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for( int p = 0; p < aux.size(); p++ )
                         ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...