Submission #44289

# Submission time Handle Problem Language Result Execution time Memory
44289 2018-03-31T09:06:50 Z JustInCase Lozinke (COCI17_lozinke) C++17
100 / 100
641 ms 17604 KB
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

const int32_t MAX_N = 20005;

string passwords[MAX_N];
map< string, bool > currSubstrings;
map< string, int32_t > substringsCnt;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int32_t n;
	cin >> n;

	for(int32_t i = 1; i <= n; i++) {
		cin >> passwords[i];
	}

	for(int32_t i = 1; i <= n; i++) {
		currSubstrings.clear();
		for(int32_t l = 0; l < (int32_t) passwords[i].size(); l++) {
			string curr = "";
			for(int32_t r = l; r < (int32_t) passwords[i].size(); r++) {
				curr += passwords[i][r];

				if(currSubstrings.count(curr) == 0) {
					currSubstrings[curr] = true;
					substringsCnt[curr]++;
				}
			}
		}
	}

	int32_t ans = 0;
	for(int32_t i = 1; i <= n; i++) {
		ans += substringsCnt[passwords[i]] - 1;
	}

	cout << ans << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1016 KB Output is correct
2 Correct 3 ms 1136 KB Output is correct
3 Correct 3 ms 1136 KB Output is correct
4 Correct 4 ms 1136 KB Output is correct
5 Correct 14 ms 1448 KB Output is correct
6 Correct 21 ms 1568 KB Output is correct
7 Correct 30 ms 2164 KB Output is correct
8 Correct 59 ms 3252 KB Output is correct
9 Correct 116 ms 3252 KB Output is correct
10 Correct 287 ms 8300 KB Output is correct
11 Correct 216 ms 8300 KB Output is correct
12 Correct 590 ms 17604 KB Output is correct
13 Correct 404 ms 17604 KB Output is correct
14 Correct 403 ms 17604 KB Output is correct
15 Correct 641 ms 17604 KB Output is correct
16 Correct 342 ms 17604 KB Output is correct
17 Correct 64 ms 17604 KB Output is correct
18 Correct 47 ms 17604 KB Output is correct
19 Correct 387 ms 17604 KB Output is correct
20 Correct 172 ms 17604 KB Output is correct