Submission #48017

# Submission time Handle Problem Language Result Execution time Memory
48017 2018-05-09T11:52:44 Z E869120 Palindromes (APIO14_palindrome) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

string S; int L[100009], N, col[100009], cnts; vector<int>x[100009], y[100009];

long long Get(int pos) {
	if (pos < 0) return -1;
	if (pos >= N) return -2;
	return L[pos];
}

int main() {
	cin >> S; N = S.size();
	for (int i = 0; i < N; i++) L[i] = (S[i] - 'a');
	for (int i = 0; i < N; i++) x[0].push_back(i);

	long long maxn = 0; cnts = 1;

	for (int i = 0; i <= N / 2 + 1; i++) {
		int cnt = 0;
		for (int j = 0; j < cnts; j++) {
			if (x[j].size() == 1) { int to = x[j][0]; if (Get(to - i) == Get(to + i)) { y[cnt] = x[j]; cnt++; } continue; }
			
			vector<int>H[26];
			for (int k = 0; k < x[j].size(); k++) {
				int to = x[j][k];
				if (Get(to - i) != Get(to + i)) continue;
				H[Get(to + i)].emplace_back(to);
			}
			for (int k = 0; k < 26; k++) {
				if (H[k].size() >= 1) { y[cnt] = H[k]; cnt++; }
			}
		}
		for (int j = 0; j < cnt; j++) { x[j] = y[j]; maxn = max(maxn, 1LL * (long long)x[j].size()*(i * 2 + 1)); } cnts = cnt;
	}

	for (int i = 0; i < 100009; i++) x[i].clear(); cnts = 1;
	for (int i = 0; i < N; i++) x[0].push_back(i);

	for (int i = 0; i <= N / 2 + 1; i++) {
		int cnt = 0;
		for (int j = 0; j < cnts; j++) {
			if (x[j].size() == 1) { int to = x[j][0]; if (Get(to - i) == Get(to + i)) { y[cnt] = x[j]; cnt++; } continue; }

			vector<int>H[26];
			for (int k = 0; k < x[j].size(); k++) {
				int to = x[j][k];
				if (Get(to - i) != Get(to + i + 1)) continue;
				H[Get(to + i)].emplace_back(to);
			}
			for (int k = 0; k < 26; k++) {
				if (H[k].size() >= 1) { y[cnt] = H[k]; cnt++; }
			}
		}
		for (int j = 0; j < cnt; j++) { x[j] = y[j]; maxn = max(maxn, 1LL * x[j].size()*(i * 2 + 2)); }
		cnts = cnt;
	}
	cout << maxn << endl;
	return 0;
}

Compilation message

palindrome.cpp: In function 'int main()':
palindrome.cpp:28:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int k = 0; k < x[j].size(); k++) {
                    ~~^~~~~~~~~~~~~
palindrome.cpp:40:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for (int i = 0; i < 100009; i++) x[i].clear(); cnts = 1;
  ^~~
palindrome.cpp:40:49: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for (int i = 0; i < 100009; i++) x[i].clear(); cnts = 1;
                                                 ^~~~
palindrome.cpp:49:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int k = 0; k < x[j].size(); k++) {
                    ~~^~~~~~~~~~~~~
palindrome.cpp:58:94: error: no matching function for call to 'max(long long int&, long long unsigned int)'
   for (int j = 0; j < cnt; j++) { x[j] = y[j]; maxn = max(maxn, 1LL * x[j].size()*(i * 2 + 2)); }
                                                                                              ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from palindrome.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
palindrome.cpp:58:94: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   for (int j = 0; j < cnt; j++) { x[j] = y[j]; maxn = max(maxn, 1LL * x[j].size()*(i * 2 + 2)); }
                                                                                              ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from palindrome.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
palindrome.cpp:58:94: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   for (int j = 0; j < cnt; j++) { x[j] = y[j]; maxn = max(maxn, 1LL * x[j].size()*(i * 2 + 2)); }
                                                                                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from palindrome.cpp:4:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
palindrome.cpp:58:94: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   for (int j = 0; j < cnt; j++) { x[j] = y[j]; maxn = max(maxn, 1LL * x[j].size()*(i * 2 + 2)); }
                                                                                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from palindrome.cpp:4:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
palindrome.cpp:58:94: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   for (int j = 0; j < cnt; j++) { x[j] = y[j]; maxn = max(maxn, 1LL * x[j].size()*(i * 2 + 2)); }
                                                                                              ^