제출 #82890

#제출 시각아이디문제언어결과실행 시간메모리
82890MilkiLozinke (COCI17_lozinke)C++14
100 / 100
286 ms16460 KiB
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) (int)x.size()
#define pb(x) push_back(x)

typedef long long ll;
typedef pair<int, int> point;

const int MAXN = 2e4 + 5;

string s[MAXN];
unordered_map<string, int> M;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);

    int n; cin >> n;
    REP(i, n){
        cin >> s[i];
        M[s[i]] ++;
    }

    ll sol = 0;
    REP(i, n){
        unordered_set<string> S;
        REP(j, sz(s[i])){
            string x = "";
            FOR(k, j, sz(s[i])){
                x += s[i][k];
                S.insert(x);
            }
        }
        for(auto it : S)
            sol += M[it];
    }
    cout << sol - n;
}
#Verdict Execution timeMemoryGrader output
Fetching results...