Submission #144273

# Submission time Handle Problem Language Result Execution time Memory
144273 2019-08-16T12:52:08 Z Divia Lozinke (COCI17_lozinke) C++14
100 / 100
262 ms 2392 KB
#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[20005],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

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 time Memory Grader output
1 Correct 3 ms 1016 KB Output is correct
2 Correct 3 ms 1016 KB Output is correct
3 Correct 3 ms 892 KB Output is correct
4 Correct 4 ms 1016 KB Output is correct
5 Correct 11 ms 1016 KB Output is correct
6 Correct 17 ms 1016 KB Output is correct
7 Correct 21 ms 1016 KB Output is correct
8 Correct 31 ms 1016 KB Output is correct
9 Correct 100 ms 1656 KB Output is correct
10 Correct 145 ms 1400 KB Output is correct
11 Correct 166 ms 1952 KB Output is correct
12 Correct 262 ms 1784 KB Output is correct
13 Correct 238 ms 1988 KB Output is correct
14 Correct 210 ms 2392 KB Output is correct
15 Correct 262 ms 2176 KB Output is correct
16 Correct 191 ms 1144 KB Output is correct
17 Correct 79 ms 1084 KB Output is correct
18 Correct 64 ms 1016 KB Output is correct
19 Correct 218 ms 2032 KB Output is correct
20 Correct 137 ms 1144 KB Output is correct