Submission #554689

#TimeUsernameProblemLanguageResultExecution timeMemory
554689new_accLozinke (COCI17_lozinke)C++14
100 / 100
143 ms41132 KiB
#include<bits/stdc++.h> #define fi first #define se second #define pitem item* using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<ll> vl; const int N=1e6+10; const int SS=1<<19; const int INFi=2e9; const ll INFl=1e13; const ll mod=998244353; const ll mod2=1e9+7; const ll mod3=1000696969; const ll p=70032301; const ull p2=913; const int L=20; int t[N]; string s[N]; unordered_map<ull,int> m; unordered_map<ull,bool> m2; void solve(){ int n; cin>>n; for(int i=1;i<=n;i++){ cin>>s[i]; ull akth=0; for(int j=0;j<s[i].size();j++) akth=akth*p2+s[i][j]; m[akth]++; } ll res=0; for(int i=1;i<=n;i++){ for(int j=0;j<s[i].size();j++){ ull akth=0; for(int k=j;k<s[i].size();k++){ akth=(akth*p2+s[i][k]); if(m2[akth]) continue; res+=m[akth]; m2[akth]=1; } } m2.clear(); res--; } cout<<res<<"\n"; } int main(){ ios_base::sync_with_stdio(0),cin.tie(0); solve(); }

Compilation message (stderr)

lozinke.cpp: In function 'void solve()':
lozinke.cpp:30:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   for(int j=0;j<s[i].size();j++) akth=akth*p2+s[i][j];
      |               ~^~~~~~~~~~~~
lozinke.cpp:35:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |   for(int j=0;j<s[i].size();j++){
      |               ~^~~~~~~~~~~~
lozinke.cpp:37:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |    for(int k=j;k<s[i].size();k++){
      |                ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...