Submission #730942

#TimeUsernameProblemLanguageResultExecution timeMemory
730942TheSahibLozinke (COCI17_lozinke)C++14
100 / 100
235 ms13644 KiB
#include <bits/stdc++.h> #define ll long long #define pii pair<int, int> const int oo = int(1e9) + 9; using namespace std; int n; string arr[20006]; ll hashs[20006]; map<ll, int> mp; int main(){ cin >> n; for (int i = 0; i < n; ++i) { string s; cin >> s; arr[i] = s; set<ll> st; for (int j = 0; j < s.size(); ++j) { ll h = 0; for (int k = j; k < s.size(); k++) { h = (h * 26) + s[k] - 'a' + 1; st.insert(h); if(j == 0 && k == s.size() - 1){ hashs[i] = h; } } } for(auto& a:st){ mp[a]++; } } ll ans = 0; for (int i = 0; i < n; i++) { ans += mp[hashs[i]] - 1; } cout << ans << '\n'; }

Compilation message (stderr)

lozinke.cpp: In function 'int main()':
lozinke.cpp:21:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         for (int j = 0; j < s.size(); ++j)
      |                         ~~^~~~~~~~~~
lozinke.cpp:24:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |             for (int k = j; k < s.size(); k++)
      |                             ~~^~~~~~~~~~
lozinke.cpp:28:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |                 if(j == 0 && k == s.size() - 1){
      |                              ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...