# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
303989 |
2020-09-20T22:55:29 Z |
FlashGamezzz |
Rima (COCI17_rima) |
C++17 |
|
1000 ms |
262148 KB |
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <queue>
using namespace std;
vector<int> lets[3000000];
bool endb[3000000] = {};
int dp[3000000] = {}, sz = 0, ans = 0;
void add(int c, int i, string s){
if (i == s.length()){
endb[c] = true; return;
}
int l = int(s[s.length()-i-1])-97;
if (lets[c][l] == 0){
lets[sz].resize(26, 0);
lets[c][l] = sz; sz++;
}
add(lets[c][l], i+1, s);
}
void solve(int c){
int t = 0;
for (int i = 0; i < 26; i++){
if (lets[c][i] != 0){
solve(lets[c][i]);
t += dp[lets[c][i]];
}
}
if (endb[c]){
t++; dp[c] = t;
}
if (c > 0){
ans = max(ans, t);
}
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(NULL);
int n; cin >> n;
lets[sz].resize(26, 0); sz++;
for (int i = 0; i < n; i++){
string s; cin >> s;
add(0, 0, s);
}
solve(0);
cout << ans << endl;
}
Compilation message
rima.cpp: In function 'void add(int, int, std::string)':
rima.cpp:18:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | if (i == s.length()){
| ~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
70904 KB |
Output is correct |
2 |
Correct |
45 ms |
70904 KB |
Output is correct |
3 |
Correct |
45 ms |
70904 KB |
Output is correct |
4 |
Incorrect |
483 ms |
141176 KB |
Output isn't correct |
5 |
Execution timed out |
1094 ms |
79000 KB |
Time limit exceeded |
6 |
Runtime error |
195 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
7 |
Runtime error |
187 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
8 |
Runtime error |
191 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
9 |
Runtime error |
346 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
10 |
Runtime error |
197 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |