답안 #138628

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

const int DIM = 20005;

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

void solve(int n) {
	mmp.clear();
	for (int i = 1; i <= n; ++i) {
		set<string> mst;
		for (int p1 = 0; p1 < str[i].length(); ++p1)
			for (int p2 = p1; p2 < str[i].length(); ++p2)
				mst.insert(str[i].substr(p1, p2 - p1 + 1));
		for (string s : mst)
			mmp[s]++;
	}
}

int main(void) {
#ifdef HOME
	freopen("lozinke.in", "r", stdin);
	freopen("lozinke.out", "w", stdout);
#endif
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%s", aux + 1);
		int m = strlen(aux + 1);
		for (int j = 1; j <= m; ++j)
			str[i].push_back(aux[j]);
	}
	solve(n);
	int ans = 0;
	for (int i = 1; i <= n; ++i)
		ans += mmp[str[i]];
	cout << ans - n;
	return 0;
}

Compilation message

lozinke.cpp: In function 'void solve(int)':
lozinke.cpp:14:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int p1 = 0; p1 < str[i].length(); ++p1)
                    ~~~^~~~~~~~~~~~~~~~~
lozinke.cpp:15:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int p2 = p1; p2 < str[i].length(); ++p2)
                      ~~~^~~~~~~~~~~~~~~~~
lozinke.cpp: In function 'int main()':
lozinke.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
lozinke.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", aux + 1);
   ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 888 KB Output is correct
2 Correct 3 ms 1016 KB Output is correct
3 Correct 3 ms 1016 KB Output is correct
4 Correct 4 ms 1016 KB Output is correct
5 Correct 12 ms 1268 KB Output is correct
6 Correct 19 ms 1272 KB Output is correct
7 Correct 26 ms 2040 KB Output is correct
8 Correct 39 ms 2812 KB Output is correct
9 Correct 99 ms 2784 KB Output is correct
10 Correct 219 ms 7840 KB Output is correct
11 Correct 169 ms 4412 KB Output is correct
12 Correct 485 ms 16580 KB Output is correct
13 Correct 293 ms 2748 KB Output is correct
14 Correct 336 ms 15060 KB Output is correct
15 Correct 512 ms 16504 KB Output is correct
16 Correct 279 ms 1144 KB Output is correct
17 Correct 67 ms 1016 KB Output is correct
18 Correct 49 ms 1016 KB Output is correct
19 Correct 338 ms 8628 KB Output is correct
20 Correct 136 ms 1144 KB Output is correct