Submission #412563

#TimeUsernameProblemLanguageResultExecution timeMemory
412563LastRoninPalindromes (APIO14_palindrome)C++14
Compilation error
0 ms0 KiB
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ll long long
using namespace std;

const ll N = 1e5 + 10;

string a;
int main() {
	speed;
	cin >> a;
	int n = a.size();
	a = '#' + a;
	ll ans = 0;
	for(int i = 1; i <= n; i++) {
	    string b;
		for(int j = i; j <= n; j++) {
			b += a[j];
			if((j - i)%2)continue;
			bool can = 1;
			for(int l = 0; l < b.size(); l++)
				if(b[l] != b[b.size() - l - 1])can = 0;
			if(!can)continue;
			ll cnt = 0;
			for(int l = 1; l <= n; l++) {
				string c = a.substr(l, b.size());
				if(c == b)
					cnt++;
			 }
			 ans = max(ans, cnt * b.size());
		}
	}
	cout << ans;
}

Compilation message (stderr)

palindrome.cpp: In function 'int main()':
palindrome.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 l = 0; l < b.size(); l++)
      |                   ~~^~~~~~~~~~
palindrome.cpp:31:34: error: no matching function for call to 'max(long long int&, long long unsigned int)'
   31 |     ans = max(ans, cnt * b.size());
      |                                  ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from palindrome.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
palindrome.cpp:31:34: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   31 |     ans = max(ans, cnt * b.size());
      |                                  ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from palindrome.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
palindrome.cpp:31:34: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   31 |     ans = max(ans, cnt * b.size());
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from palindrome.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
palindrome.cpp:31:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   31 |     ans = max(ans, cnt * b.size());
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from palindrome.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
palindrome.cpp:31:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   31 |     ans = max(ans, cnt * b.size());
      |                                  ^