# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1029827 | 2024-07-21T11:42:34 Z | earlyamazon | Savez (COCI15_savez) | C++14 | 1000 ms | 65544 KB |
// wzorcowka KMP i trie #include <bits/stdc++.h> using namespace std; const int mn = 2e6+7; const int ALF = 2; int n, terwyn, wyn, wsk = 2; vector<int> ps; vector<int> sas[mn]; int dp[mn]; void zejdz(string s, int ind=1, int poz=0, int indps=0){ // cout<<"a: "<<s<<" "<<indps<<" "<<poz<<" "<<ind<<"\n"; if (indps < ps.size() && ps[indps] == poz) { terwyn = max(terwyn, dp[ind]); indps++; } if (poz == s.size()){ dp[ind] = terwyn + 1; wyn = max(wyn, dp[ind]); return; } if (sas[ind].size() < ALF) sas[ind].resize(ALF); if (!sas[ind][s[poz]-'A']){ sas[ind][s[poz]-'A'] = wsk++; } zejdz(s, sas[ind][s[poz] - 'A'], poz+1, indps); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; string s; sas[1].resize(ALF); for (int i = 0; i < n; i++){ cin>>s; vector<int> pi = {0}; ps.clear(); ps.push_back(s.size()); terwyn = 0; for (int j = 1; j < s.size(); j++){ int k = pi.back(); while (s[j] != s[k] && k){ k = pi[k-1]; } pi.push_back(k); if (s[j] == s[k]) { pi.back()++; } } // for (auto j : pi) cout<<j<<" "; // cout<<"\n"; int k = pi.back(); while (k){ ps.push_back(k); k = pi[k-1]; } reverse(ps.begin(), ps.end()); // for (auto j : ps) cout<<j<<" "; // cout<<"\n"; zejdz(s); } cout<<wyn<<"\n"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2275 ms | 65544 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2150 ms | 65536 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2165 ms | 65536 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2180 ms | 65536 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2113 ms | 65536 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2151 ms | 65536 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2162 ms | 65536 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2342 ms | 65536 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 70 ms | 48540 KB | Output is correct |
2 | Correct | 75 ms | 48412 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2171 ms | 65536 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |