Submission #141091

# Submission time Handle Problem Language Result Execution time Memory
141091 2019-08-06T16:23:40 Z SeekingOblivion Lozinke (COCI17_lozinke) C++14
100 / 100
316 ms 2424 KB
#include<iostream>
#include<fstream>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#define fin cin
#define fout cout
#include<vector>
using namespace std;
//ifstream fin("date.in");
//ofstream fout("date.out");
map<string,int> m;
set<string> s;
set<string>::iterator it;
int n,i,j,h,p,sol;
pair<int,int> v[20010];
string c[20010];
int main(){
    fin>>n;
    for(i=1;i<=n;i++)
    {
        fin>>c[i];
        v[i].first=c[i].size();
        v[i].second=i;
    }
    sort(v+1, v+n+1);
    for(i=1;i<=n;i++)
    {
        s.clear();
        p=v[i].second;
        for(j=0;c[p][j];j++)
            for(h=j;c[p][h];h++)
                s.insert(c[p].substr(j,h-j+1));
        for(it=s.begin();it!=s.end();it++)
        {
            if(m.find(*it)!=m.end())
            {
                sol+=m[*it];
                if(*it==c[p]) sol+=m[*it];
            }
        }
        if(m.find(c[p])==m.end())
            m[c[p]]=1;
        else
            m[c[p]]++;
    }
    fout<<sol;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 888 KB Output is correct
2 Correct 2 ms 888 KB Output is correct
3 Correct 3 ms 888 KB Output is correct
4 Correct 4 ms 1016 KB Output is correct
5 Correct 11 ms 1016 KB Output is correct
6 Correct 19 ms 1032 KB Output is correct
7 Correct 20 ms 1016 KB Output is correct
8 Correct 26 ms 1144 KB Output is correct
9 Correct 95 ms 1528 KB Output is correct
10 Correct 141 ms 1504 KB Output is correct
11 Correct 150 ms 1796 KB Output is correct
12 Correct 270 ms 1812 KB Output is correct
13 Correct 302 ms 2204 KB Output is correct
14 Correct 206 ms 2424 KB Output is correct
15 Correct 293 ms 2168 KB Output is correct
16 Correct 316 ms 1148 KB Output is correct
17 Correct 78 ms 1144 KB Output is correct
18 Correct 61 ms 1144 KB Output is correct
19 Correct 244 ms 2040 KB Output is correct
20 Correct 164 ms 1272 KB Output is correct