Submission #104701

# Submission time Handle Problem Language Result Execution time Memory
104701 2019-04-09T00:56:32 Z Shtef Dijamant (COI16_dijament) C++14
0 / 100
3 ms 384 KB
#include <iostream>

using namespace std;

typedef long long ll;

string s;
int n, cnt1[100005], cnt2[100005];

ll brojpalin(){
	ll ret = 0;
	int l = 0, r = -1;
	for(int i = 0 ; i < n ; ++i){
		int k = (i > r ? 1 : min(cnt1[l + r - i], r - i + 1));
		while(i - k >= 0 && i + k < n && s[i - k] == s[i + k]){
			k++;
		}
		cnt1[i] = k--;
		if(i + k > r){
			l = i - k;
			r = i + k;
		}
		ret += k + 1;
		int x = i - k + 1, y = i + k + 1;
	}
	l = 0;
	r = -1;
	for(int i = 0 ; i < n ; ++i){
		int k = (i > r ? 0 : min(cnt1[l + r - i + 1], r - i + 1));
		while(i - k - 1 >= 0 && i + k < n && s[i - k - 1] == s[i + k]){
			k++;
		}
		cnt1[i] = k--;
		if(i + k > r){
			l = i - k - 1;
			r = i + k;
		}
		ret += k + 1;
	}
	return ret;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> s;
n = (int)s.size();
ll sol = brojpalin();
for(int i = 0 ; i < n ; ++i){
	char poc = s[i];
	for(int j = 0 ; j < 26 ; ++j){
		s[i] = j + 'a';
		sol = max(sol, brojpalin());
	}
	s[i] = poc;
}
cout << sol << endl;

return 0;
}

Compilation message

dijament.cpp: In function 'll brojpalin()':
dijament.cpp:24:7: warning: unused variable 'x' [-Wunused-variable]
   int x = i - k + 1, y = i + k + 1;
       ^
dijament.cpp:24:22: warning: unused variable 'y' [-Wunused-variable]
   int x = i - k + 1, y = i + k + 1;
                      ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -