Submission #85398

#TimeUsernameProblemLanguageResultExecution timeMemory
85398MohamedAhmed0Lozinke (COCI17_lozinke)C++14
100 / 100
556 ms17772 KiB
#include <bits/stdc++.h> using namespace std; bool cmp(string &s , string &s1) { return s.size() < s1.size() ; } int main() { int n ; cin>>n ; string arr[n] ; for(int i = 0 ; i < n ; ++i) cin>>arr[i] ; sort(arr , arr + n , cmp) ; long long ans = 0ll ; map<string , int>mp ; for(int i = 0 ; i < n ; ++i) { string s = arr[i] ; map<string , int>mp2 ; ans += mp[s] ; for(int j = 0 ; j < s.size() ; ++j) { string s1 = "" ; for(int k = j ; k < s.size() ; ++k) { s1 += s[k] ; if(mp2[s1] != 1) ans += mp[s1] * 1ll ; mp2[s1] = 1 ; } } mp[s]++; } return cout<<ans , 0 ; }

Compilation message (stderr)

lozinke.cpp: In function 'int main()':
lozinke.cpp:25:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 0 ; j < s.size() ; ++j)
                         ~~^~~~~~~~~~
lozinke.cpp:28:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int k = j ; k < s.size() ; ++k)
                             ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...