답안 #82890

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
82890 2018-11-02T15:15:56 Z Milki Lozinke (COCI17_lozinke) C++14
100 / 100
286 ms 16460 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1016 KB Output is correct
2 Correct 3 ms 1108 KB Output is correct
3 Correct 3 ms 1108 KB Output is correct
4 Correct 4 ms 1108 KB Output is correct
5 Correct 10 ms 1368 KB Output is correct
6 Correct 13 ms 1384 KB Output is correct
7 Correct 17 ms 2320 KB Output is correct
8 Correct 24 ms 3016 KB Output is correct
9 Correct 59 ms 3016 KB Output is correct
10 Correct 114 ms 7896 KB Output is correct
11 Correct 94 ms 7896 KB Output is correct
12 Correct 258 ms 16408 KB Output is correct
13 Correct 159 ms 16408 KB Output is correct
14 Correct 177 ms 16408 KB Output is correct
15 Correct 286 ms 16460 KB Output is correct
16 Correct 187 ms 16460 KB Output is correct
17 Correct 71 ms 16460 KB Output is correct
18 Correct 53 ms 16460 KB Output is correct
19 Correct 202 ms 16460 KB Output is correct
20 Correct 105 ms 16460 KB Output is correct