Submission #141684

#TimeUsernameProblemLanguageResultExecution timeMemory
141684MihneaLozinke (COCI17_lozinke)C++14
100 / 100
270 ms2296 KiB
#include<iostream> #include<map> #include<string> #include<set> #include<algorithm> using namespace std; int n,s; string st[20010],sc; set <string> a; map <string,int> b; int cmp(string a,string b) { if (a.size()!=b.size()) return a.size()<b.size(); else return a<b; } int main(){ cin>>n; int s=0; for(int i=1;i<=n;i++) cin>>st[i]; sort(st+1,st+n+1,cmp); for(int i=1;i<=n;i++) { a.clear(); for(int j=0;j<st[i].size();j++) { sc.erase( sc.begin(),sc.end() ); for(int k=j;k<st[i].size();k++) { sc.push_back(st[i][k]); a.insert(sc); } } for(set<string>::iterator it=a.begin();it!=a.end();it++) { if (b.find(*it)!=b.end()) s+=b[*it]; } if(b.find(st[i])==b.end()) b[st[i]]=1; else b[st[i]]++; } int L=1; for(int i=2;i<=n;i++) { if(st[i]==st[i-1]) L++; else L=1; s+=L-1; } cout<<s; return 0; }

Compilation message (stderr)

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