Submission #83958

# Submission time Handle Problem Language Result Execution time Memory
83958 2018-11-11T23:51:23 Z josiftepe Lozinke (COCI17_lozinke) C++14
100 / 100
519 ms 17852 KB
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = (1 << 30);
const ll inf = (1LL << 60LL);
const int maxn = 1e5 + 10;
int n;
string arr[20002];
map<string, int> mapa;
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i =0 ; i < n; i ++){
        cin >> arr[i];
    }
    for(int i =0 ; i < n; i ++){
        string s = arr[i];
        set<string> st;
        for(int j = 0; j < (int)s.size(); j ++){
            for(int k = 1; k <= (int)s.size(); k ++){
                if(j + k <= (int)s.size())
                    st.insert(s.substr(j, k));
            }
        }
        for(set<string>::iterator it = st.begin(); it != st.end(); it ++){
            mapa[*it] ++;
        }
    }
    ll ret = 0;
    for(int i =0 ; i < n; i ++){
        ret += max(0, mapa[arr[i]] - 1);
    }
    cout << ret << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 888 KB Output is correct
2 Correct 3 ms 1016 KB Output is correct
3 Correct 3 ms 1256 KB Output is correct
4 Correct 4 ms 1368 KB Output is correct
5 Correct 12 ms 1768 KB Output is correct
6 Correct 18 ms 1768 KB Output is correct
7 Correct 26 ms 2404 KB Output is correct
8 Correct 41 ms 3332 KB Output is correct
9 Correct 97 ms 3332 KB Output is correct
10 Correct 219 ms 8444 KB Output is correct
11 Correct 162 ms 8444 KB Output is correct
12 Correct 476 ms 17624 KB Output is correct
13 Correct 293 ms 17624 KB Output is correct
14 Correct 345 ms 17624 KB Output is correct
15 Correct 519 ms 17852 KB Output is correct
16 Correct 281 ms 17852 KB Output is correct
17 Correct 67 ms 17852 KB Output is correct
18 Correct 53 ms 17852 KB Output is correct
19 Correct 339 ms 17852 KB Output is correct
20 Correct 138 ms 17852 KB Output is correct