# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
244909 |
2020-07-05T09:12:34 Z |
NONAME |
Rima (COCI17_rima) |
C++14 |
|
373 ms |
150520 KB |
#include <bits/stdc++.h>
#define dbg(x) cerr << #x << " = " << x << "\n"
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie()
using namespace std;
using ll = long long;
const int N = 5e5 + 10;
int n, ans = 1;
string s[N];
struct trie {
trie *nxt[26];
int cnt, res;
trie() {
for (int i = 0; i < 26; ++i)
nxt[i] = 0;
cnt = 0;
res = 0;
}
void add(string &t, int p = 0) {
if (p == int(t.size())) {
++cnt;
return;
}
int j = t[p] - 'a';
if (nxt[j] == 0)
nxt[j] = new trie();
nxt[j] -> add(t, p + 1);
}
void f(int x) {
for (int i = 0; i < 26; ++i)
if (nxt[i] != 0)
nxt[i] -> f(i);
for (int i = 0; i < 26; ++i)
if (nxt[i] != 0)
res += (nxt[i] -> res);
//cerr << char(x + 'a') << " " << cnt << " " << res << "\n";
ans = max(ans, res);
if (!cnt) res = 0;
else res += cnt;
}
} tr;
int main() {
fast_io;
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> s[i];
reverse(s[i].begin(), s[i].end());
tr.add(s[i]);
}
tr.f(-1);
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
16000 KB |
Output is correct |
2 |
Correct |
14 ms |
16128 KB |
Output is correct |
3 |
Correct |
16 ms |
16000 KB |
Output is correct |
4 |
Incorrect |
373 ms |
150520 KB |
Output isn't correct |
5 |
Correct |
31 ms |
19576 KB |
Output is correct |
6 |
Incorrect |
110 ms |
92944 KB |
Output isn't correct |
7 |
Incorrect |
124 ms |
92704 KB |
Output isn't correct |
8 |
Incorrect |
109 ms |
92372 KB |
Output isn't correct |
9 |
Incorrect |
133 ms |
98388 KB |
Output isn't correct |
10 |
Incorrect |
111 ms |
92416 KB |
Output isn't correct |