Submission #338719

#TimeUsernameProblemLanguageResultExecution timeMemory
338719FlashGamezzzSavez (COCI15_savez)C++11
48 / 120
60 ms20332 KiB
#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 (stderr)

savez.cpp: In function 'int main()':
savez.cpp:22:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |   for (int j = 0; j < a.length(); j++) {
      |                   ~~^~~~~~~~~~~~
savez.cpp:36:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |   for (int j = 0; j < ph[i].size(); j++){
      |                   ~~^~~~~~~~~~~~~~
#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...