# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
104124 |
2019-04-04T06:58:10 Z |
Kewo |
Savez (COCI15_savez) |
C++14 |
|
148 ms |
66560 KB |
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<char, char> cc;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;
const int N = (int)(5e5 + 5);
const int LOG = (int)(20);
struct node {
int word, ans;
map<cc, int> ed;
}tree[N];
int n, sz = 1;
string s[N];
void add(int ind, int idx, int x) {
if(x == s[ind].length() - 1) {
tree[idx].word++;
tree[idx].ans++;
return;
}
char fc = s[ind][x], lc = s[ind][(int)s[ind].length() - x - 1];
cc e = {fc, lc};
if(tree[idx].ed.count(e) == 0)
tree[idx].ed[e] = ++sz;
add(ind, tree[idx].ed[e], x + 1);
tree[idx].ans = max(tree[idx].ans, tree[tree[idx].ed[e]].ans);
}
int main() {
fast_io();
// freopen("inp.in", "r", stdin);
cin >> n;
for(int i = 1; i <= n; i++) {
cin >> s[i];
s[i].pb('$');
}
for(int i = n; i >= 1; i--)
add(i, 1, 0);
cout << tree[1].ans;
}
Compilation message
savez.cpp: In function 'void add(int, int, int)':
savez.cpp:37:7: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(x == s[ind].length() - 1) {
~~^~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
43384 KB |
Output is correct |
2 |
Correct |
44 ms |
43392 KB |
Output is correct |
3 |
Correct |
42 ms |
43384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
42 ms |
43384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
66 ms |
45560 KB |
Output is correct |
2 |
Correct |
83 ms |
45780 KB |
Output is correct |
3 |
Correct |
66 ms |
45560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
48 ms |
44092 KB |
Output is correct |
2 |
Correct |
68 ms |
46072 KB |
Output is correct |
3 |
Correct |
71 ms |
46456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
45824 KB |
Output is correct |
2 |
Correct |
66 ms |
45820 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
45812 KB |
Output is correct |
2 |
Correct |
78 ms |
45928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
45780 KB |
Output is correct |
2 |
Correct |
67 ms |
45688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
45256 KB |
Output is correct |
2 |
Correct |
69 ms |
45560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
97 ms |
43948 KB |
Output is correct |
2 |
Correct |
93 ms |
44508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
99 ms |
44300 KB |
Output is correct |
2 |
Correct |
101 ms |
44928 KB |
Output is correct |
3 |
Runtime error |
148 ms |
66560 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |