Submission #74540

#TimeUsernameProblemLanguageResultExecution timeMemory
74540ZZangZZangLozinke (COCI17_lozinke)C++17
85 / 100
1084 ms4076 KiB
#include <cstdio> #include <vector> #include <algorithm> #include <queue> #include <cstring> #include <functional> #include <string> #include <set> typedef long long ll; using namespace std; ll n, sol = 0; string s[20001]; multiset<ll> ms; ll trans(string& s) { ll ret = 0; for(ll i=0; i<s.size(); i++) ret += (ll)(s[i]-'a'+1), ret *= 27; return ret; } int main() { scanf("%lld", &n); for(ll i=0; i<n; i++) { char str[20]; scanf("%s", str); s[i] = string(str); ms.insert(trans(s[i])); } for(ll k=0; k<n; k++) { set<ll> l; vector<ll> v; ll full = trans(s[k]); for(ll i=0; i<s[k].size(); i++) { string tmp; for(ll j=i; j<s[k].size(); j++) { tmp += s[k][j]; ll ttmp = trans(tmp); if(l.find(ttmp) == l.end()) l.insert(ttmp), v.push_back(ttmp); } } for(ll i=0; i<v.size(); i++) { if(v[i] == full) sol += (ll)(ms.count(v[i]) - 1); else sol += (ll)(ms.count(v[i])); } } printf("%lld", sol); return 0; }

Compilation message (stderr)

lozinke.cpp: In function 'll trans(std::__cxx11::string&)':
lozinke.cpp:20:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(ll i=0; i<s.size(); i++) ret += (ll)(s[i]-'a'+1), ret *= 27;
              ~^~~~~~~~~
lozinke.cpp: In function 'int main()':
lozinke.cpp:38:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(ll i=0; i<s[k].size(); i++)
               ~^~~~~~~~~~~~
lozinke.cpp:41:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(ll j=i; j<s[k].size(); j++)
                ~^~~~~~~~~~~~
lozinke.cpp:48:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(ll i=0; i<v.size(); i++)
               ~^~~~~~~~~
lozinke.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &n);
  ~~~~~^~~~~~~~~~~~
lozinke.cpp:29:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   char str[20]; scanf("%s", str);
                 ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...