Submission #98817

#TimeUsernameProblemLanguageResultExecution timeMemory
98817someone_aaSavez (COCI15_savez)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair using namespace std; const int maxn = 510; const ll mod = 468395662504823; const ll k = 37; int dp[maxn], n; vector<ll>pref[maxn]; vector<ll>suff[maxn]; string codes; bool match(int i, int j) { // returns true if we can put string i at string j if(codes[i].length() > codes[j].length()) return false; if(pref[j][codes[i].length()] == pref[i][codes[i].length()] && suff[j][codes[i].length()] == suff[i][codes[i].length()]) return true; return false; } int main() { cin>>n; for(int i=1;i<=n;i++) { cin>>codes; pref[i].pb(0); ll kk = 1LL; for(int j=0;j<codes.length();j++) { ll curr = pref[i].back() + (kk * (codes[j] - 'A' + 1))%mod; curr %= mod; kk *= k; kk %= mod; pref[i].pb(curr); } kk = 1LL; suff[i].pb(0); for(int j=codes.length()-1;j>=0;j--) { ll curr = suff[i].back() + (kk * (codes[j] - 'A' + 1))%mod; curr %= mod; kk *= k; kk %= mod; suff[i].pb(curr); } } int result = 0; for(int i=1;i<=n;i++) { dp[i] = 1; for(int j=1;j<i;j++) { if(match(j, i)) { dp[i] = max(dp[i], dp[j] + 1); } } result = max(result ,dp[i]); } cout<<result<<"\n"; return 0; }

Compilation message (stderr)

savez.cpp: In function 'bool match(int, int)':
savez.cpp:17:17: error: request for member 'length' in 'codes.std::__cxx11::basic_string<char>::operator[](((std::__cxx11::basic_string<char>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<char> >::value_type {aka char}'
     if(codes[i].length() > codes[j].length()) return false;
                 ^~~~~~
savez.cpp:17:37: error: request for member 'length' in 'codes.std::__cxx11::basic_string<char>::operator[](((std::__cxx11::basic_string<char>::size_type)j))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<char> >::value_type {aka char}'
     if(codes[i].length() > codes[j].length()) return false;
                                     ^~~~~~
savez.cpp:18:25: error: request for member 'length' in 'codes.std::__cxx11::basic_string<char>::operator[](((std::__cxx11::basic_string<char>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<char> >::value_type {aka char}'
     if(pref[j][codes[i].length()] == pref[i][codes[i].length()] && suff[j][codes[i].length()] == suff[i][codes[i].length()]) return true;
                         ^~~~~~
savez.cpp:18:55: error: request for member 'length' in 'codes.std::__cxx11::basic_string<char>::operator[](((std::__cxx11::basic_string<char>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<char> >::value_type {aka char}'
     if(pref[j][codes[i].length()] == pref[i][codes[i].length()] && suff[j][codes[i].length()] == suff[i][codes[i].length()]) return true;
                                                       ^~~~~~
savez.cpp:18:85: error: request for member 'length' in 'codes.std::__cxx11::basic_string<char>::operator[](((std::__cxx11::basic_string<char>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<char> >::value_type {aka char}'
     if(pref[j][codes[i].length()] == pref[i][codes[i].length()] && suff[j][codes[i].length()] == suff[i][codes[i].length()]) return true;
                                                                                     ^~~~~~
savez.cpp:18:115: error: request for member 'length' in 'codes.std::__cxx11::basic_string<char>::operator[](((std::__cxx11::basic_string<char>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<char> >::value_type {aka char}'
     if(pref[j][codes[i].length()] == pref[i][codes[i].length()] && suff[j][codes[i].length()] == suff[i][codes[i].length()]) return true;
                                                                                                                   ^~~~~~
savez.cpp: In function 'int main()':
savez.cpp:29:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=0;j<codes.length();j++) {
                     ~^~~~~~~~~~~~~~~