# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
338719 | 2020-12-23T18:45:16 Z | FlashGamezzz | Savez (COCI15_savez) | C++11 | 60 ms | 20332 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<long long> ph[2000], sh[2000]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; for (int i = 0; i < n; i++){ string a; cin >> a; long long pow = 1, h = 0; for (int j = 0; j < a.length(); j++) { h += (a[j]-'A'+1)*pow; h %= m; ph[i].push_back(h); pow *= p; pow %= m; } h = 0; for (int j = a.length()-1; j >= 0; j--) { h *= p; h %= m; h += (a[j]-'A'+1); h %= m; sh[i].push_back(h); } } unordered_map<long long, 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<long long, 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 | 1 ms | 492 KB | Output is correct |
2 | Correct | 1 ms | 492 KB | Output is correct |
3 | Correct | 1 ms | 492 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 492 KB | Output is correct |
2 | Correct | 1 ms | 492 KB | Output is correct |
3 | Correct | 4 ms | 1772 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 55 ms | 17388 KB | Output is correct |
2 | Correct | 55 ms | 17536 KB | Output is correct |
3 | Correct | 60 ms | 19948 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2028 KB | Output is correct |
2 | Correct | 44 ms | 19564 KB | Output is correct |
3 | Correct | 49 ms | 20332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 22 ms | 12780 KB | Execution killed with signal 6 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 11 ms | 5612 KB | Execution killed with signal 6 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 8 ms | 3436 KB | Execution killed with signal 6 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 6 ms | 2412 KB | Execution killed with signal 6 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 5 ms | 1516 KB | Execution killed with signal 6 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 1132 KB | Execution killed with signal 6 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |