답안 #138620

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
138620 2019-07-30T07:29:55 Z KCSC Lozinke (COCI17_lozinke) C++14
5 / 100
809 ms 55800 KB
#include <bits/stdc++.h>
using namespace std;

const int DIM = 20005;

string str[DIM];
map<string, set<int>> mmp;

void solve(int n, int &ans) {
	mmp.clear();
	for (int i = 1; i <= n; ++i) {
		ans += mmp[str[i]].size();
		for (int p1 = 0; p1 < str[i].length(); ++p1)
			for (int p2 = p1; p2 < str[i].length(); ++p2)
				mmp[str[i].substr(p1, p2 - p1 + 1)].insert(i);
	}
}

inline bool cmp(string s1, string s2) {
	return s1.length() > s2.length();
}

int main(void) {
#ifdef HOME
	freopen("lozinke.in", "r", stdin);
	freopen("lozinke.out", "w", stdout);
#endif
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> str[i];
	sort(str + 1, str + n + 1, cmp);
	int ans = 0;
	solve(n, ans);
	for (int i = 1, j = 1; i <= n; i = j) {
		while (j <= n and str[i] == str[j])
			++j;
		ans += j - i - 1;
	}
	cout << ans;
	return 0;
}

Compilation message

lozinke.cpp: In function 'void solve(int, int&)':
lozinke.cpp:13:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int p1 = 0; p1 < str[i].length(); ++p1)
                    ~~~^~~~~~~~~~~~~~~~~
lozinke.cpp:14:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int p2 = p1; p2 < str[i].length(); ++p2)
                      ~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1020 KB Output is correct
2 Incorrect 3 ms 1016 KB Output isn't correct
3 Incorrect 3 ms 1148 KB Output isn't correct
4 Incorrect 4 ms 1144 KB Output isn't correct
5 Incorrect 14 ms 2552 KB Output isn't correct
6 Incorrect 24 ms 3192 KB Output isn't correct
7 Incorrect 31 ms 4728 KB Output isn't correct
8 Incorrect 45 ms 7032 KB Output isn't correct
9 Incorrect 160 ms 12664 KB Output isn't correct
10 Incorrect 325 ms 26728 KB Output isn't correct
11 Incorrect 289 ms 20216 KB Output isn't correct
12 Incorrect 758 ms 54136 KB Output isn't correct
13 Incorrect 617 ms 31352 KB Output isn't correct
14 Incorrect 495 ms 43192 KB Output isn't correct
15 Incorrect 809 ms 55800 KB Output isn't correct
16 Incorrect 627 ms 33144 KB Output isn't correct
17 Incorrect 215 ms 10360 KB Output isn't correct
18 Incorrect 117 ms 8448 KB Output isn't correct
19 Incorrect 571 ms 36712 KB Output isn't correct
20 Incorrect 313 ms 18524 KB Output isn't correct