Submission #144271

#TimeUsernameProblemLanguageResultExecution timeMemory
144271DiviaLozinke (COCI17_lozinke)C++14
40 / 100
24 ms760 KiB
#include <iostream> #include <algorithm> #include <set> #include <map> #include <string> using namespace std; //ifstream cin("lozinke.in"); //ofstream cout("lozinke.out"); int n,i,j,k,sol; string s[2005],aux; set <string> sett; map <string,int> mapp; set <string> ::iterator it; map <string,int> ::iterator itt; int cmp(string a,string b){ if(a.size()!=b.size())return a.size()<b.size(); return a<b; } int main(){ cin>>n; for(i=1;i<=n;i++) cin>>s[i]; sort(s+1,s+n+1,cmp); for(i=1;i<=n;i++){ sett.clear(); for(j=0;j<s[i].size();j++){ aux.erase(aux.begin(),aux.end()); for(k=j;k<s[i].size();k++){ aux.push_back(s[i][k]); sett.insert(aux); } } for(it=sett.begin();it!=sett.end();it++) if(mapp.find(*it)!=mapp.end()) sol+=mapp[*it]; if(mapp.find(s[i])!=mapp.end()) mapp[s[i]]++; else mapp[s[i]]=1; } for(itt=mapp.begin();itt!=mapp.end();itt++) sol+=(itt->second)*(itt->second-1)/2; cout<<sol; return 0; }

Compilation message (stderr)

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