제출 #1340475

#제출 시각아이디문제언어결과실행 시간메모리
1340475kawhietLozinke (COCI17_lozinke)C++20
40 / 100
1096 ms836 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<string> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    auto is = [&](string x, string y) {
        int n = x.size(), m = y.size();
        if (n > m) return false;
        for (int i = 0; i + n <= m; i++) {
            if (y.substr(i, n) == x) {
                return true;
            }
        }
        return false;
    };
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j == i) continue;
            ans += is(a[i], a[j]);
        }
    }
    cout << ans << '\n';
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...