Submission #116818

#TimeUsernameProblemLanguageResultExecution timeMemory
116818tuanasanhLozinke (COCI17_lozinke)C++17
100 / 100
562 ms16488 KiB
#include <bits/stdc++.h> #pragma O3 using namespace std; long long n,ans=0LL; vector<string> r; string s; map<string,int> mp; bool cmp(string &a,string &b){ return a.length()<b.length(); } int main(){ cin>>n; for(int i=0;i<n;i++){ cin>>s; r.push_back(s); } sort(r.begin(),r.end(),cmp); for(int i=0;i<n;i++){ s=r[i]; ans+=mp[s]; map<string,int> mp2; for(int j=0;j<s.length();j++){ string tmp=""; for(int k=j;k<s.length();k++){ tmp+=s[k]; if(mp2[tmp]==0) ans+=mp[tmp]; mp2[tmp]++; } } mp[s]++; } cout<<ans; }

Compilation message (stderr)

lozinke.cpp:2:0: warning: ignoring #pragma O3  [-Wunknown-pragmas]
 #pragma O3
 
lozinke.cpp: In function 'int main()':
lozinke.cpp:22:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<s.length();j++){
               ~^~~~~~~~~~~
lozinke.cpp:24:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int k=j;k<s.length();k++){
                ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...