# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
136520 | mariusnicoli | Lozinke (COCI17_lozinke) | C++14 | 270 ms | 2312 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <map>
#include <string>
#include <set>
#include <algorithm>
using namespace std;
map<string, int> m;
int n, i, sol;
string s[20010], sc;
set<string> st;
int cmp(string a, string b) {
if (a.size() != b.size())
return a.size()<b.size();
else
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++) {
st.clear();
for (int j=0;j<s[i].size();j++) {
sc.erase(sc.begin(), sc.end());
for (int k=j;k<s[i].size();k++) {
sc.push_back(s[i][k]);
st.insert(sc);
}
}
for (set<string>:: iterator it = st.begin(); it != st.end(); it++) {
if (m.find(*it) != m.end())
sol += m[*it];
}
if (m.find(s[i]) == m.end())
m[s[i]] = 1;
else
m[s[i]]++;
}
/**
for (map<string,int>::iterator it = m.begin(); it!=m.end(); it++)
cout<<it->first<<" "<<it->second<<"\n";
**/
int L = 1;
for (i=2;i<=n;i++) {
if (s[i] == s[i-1])
L++;
else
L = 1;
sol += L-1;
}
cout<<sol;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |