# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
338722 | 2020-12-23T18:51:32 Z | FlashGamezzz | Savez (COCI15_savez) | C++11 | 150 ms | 65540 KB |
#include <iostream> #include <cstdlib> #include <cstdio> #include <fstream> #include <algorithm> #include <utility> #include <vector> #include <iostream> #include <string> #include <unordered_map> using namespace std; int n, p = 31, m = 1000000009; vector< vector<int> > ph, sh; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; long long pow = 1, h = 0; vector<int> temp; for (int i = 0; i < n; i++){ string a; cin >> a; pow = 1, h = 0; temp.clear(); for (int j = 0; j < a.length(); j++) { h += (a[j]-'A'+1)*pow; h %= m; temp.push_back((int) h); pow *= p; pow %= m; } ph.push_back(temp); h = 0; temp.clear(); for (int j = a.length()-1; j >= 0; j--) { h *= p; h %= m; h += (a[j]-'A'+1); h %= m; temp.push_back((int) h); } sh.push_back(temp); } unordered_map<int, int> subsq; int ans = 0; for (int i = 0; i < n; i++){ int mv = 0; for (int j = 0; j < ph[i].size(); j++){ if (ph[i][j] == sh[i][j]){ unordered_map<int, int>::iterator it = subsq.find(ph[i][j]); if (it != subsq.end()){ mv = max(mv, it->second); } } } subsq[ph[i][ph[i].size()-1]] = mv+1; ans = max(ans, mv+1); } cout << ans << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | Output is correct |
2 | Correct | 0 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 3 ms | 1004 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 42 ms | 8172 KB | Output is correct |
2 | Correct | 47 ms | 8300 KB | Output is correct |
3 | Correct | 49 ms | 8300 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 876 KB | Output is correct |
2 | Correct | 35 ms | 8020 KB | Output is correct |
3 | Correct | 39 ms | 8428 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 41 ms | 8556 KB | Output is correct |
2 | Correct | 40 ms | 8812 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 45 ms | 9564 KB | Output is correct |
2 | Correct | 42 ms | 9564 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 53 ms | 11092 KB | Output is correct |
2 | Correct | 48 ms | 11092 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 60 ms | 14292 KB | Output is correct |
2 | Correct | 57 ms | 13908 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 102 ms | 26804 KB | Output is correct |
2 | Correct | 98 ms | 26824 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 150 ms | 44452 KB | Output is correct |
2 | Correct | 146 ms | 44308 KB | Output is correct |
3 | Runtime error | 145 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |