답안 #234430

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
234430 2020-05-24T08:05:35 Z NONAME Lozinke (COCI17_lozinke) C++17
100 / 100
469 ms 19264 KB
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#define N 100500
#define oo ll(1e16)
#define ft first
#define sd second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define el '\n'
#define elf endl
#define base ll(1e9 + 7)
using namespace std;
typedef long long ll;
typedef long double ld;

int n, ans;
string s[N];
map <string, int> ma;

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

    cin >> n;
    for (int i = 0; i < n; i++) {
		cin >> s[i];
		int len = sz(s[i]);
		set <string> se;
		se.clear();
		for (int l = 0; l < len; l++) {
			string t;
			for (int r = l; r < len; r++) {
                t += s[i][r];
                se.insert(t);
			}
		}

        for (string t : se)
			ma[t]++;
    }

    for (int i = 0; i < n; i++)
		ans += ma[s[i]];

	cout << ans - n;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3456 KB Output is correct
2 Correct 6 ms 3456 KB Output is correct
3 Correct 7 ms 3456 KB Output is correct
4 Correct 9 ms 3584 KB Output is correct
5 Correct 16 ms 3840 KB Output is correct
6 Correct 22 ms 3840 KB Output is correct
7 Correct 30 ms 4608 KB Output is correct
8 Correct 40 ms 5368 KB Output is correct
9 Correct 100 ms 5368 KB Output is correct
10 Correct 211 ms 10360 KB Output is correct
11 Correct 162 ms 7032 KB Output is correct
12 Correct 453 ms 19264 KB Output is correct
13 Correct 283 ms 5368 KB Output is correct
14 Correct 304 ms 17528 KB Output is correct
15 Correct 469 ms 19064 KB Output is correct
16 Correct 293 ms 3832 KB Output is correct
17 Correct 88 ms 3704 KB Output is correct
18 Correct 64 ms 3584 KB Output is correct
19 Correct 327 ms 11188 KB Output is correct
20 Correct 145 ms 3712 KB Output is correct