Submission #107730

#TimeUsernameProblemLanguageResultExecution timeMemory
107730ahmad_salahSavez (COCI15_savez)C++17
24 / 120
1078 ms44108 KiB
#include <bits/stdc++.h> using namespace std; const int M = 1e6; vector<string> v; int n, memo[M] = {}; bool check(string s1, string s2) { if (s2.size() < s1.size()) return false; for (int i = 0; i < s1.size(); i++) if (s1[i] != s2[i]) return false; while (!s1.empty()) { if (s1.back() != s2.back()) return false; s1.pop_back(); s2.pop_back(); } return true; } int solve(int i) { int &r = memo[i]; if (!r) { r = 1; for (int j = i + 1; j < n; j++) { if (check(v[i], v[j])) r = max(r, 1 + solve(j)); } } return r; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int ans = 0; cin >> n; while (n--) { string s; cin >> s; v.push_back(s); } n = v.size(); for (int i = 0; i < n; i++) ans = max(ans, solve(i)); cout << ans << '\n'; return 0; }

Compilation message (stderr)

savez.cpp: In function 'bool check(std::__cxx11::string, std::__cxx11::string)':
savez.cpp:13:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < s1.size(); i++)
                     ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...