Warning: mkdir(): No space left on device in /var/www/tgoop/post.php on line 37

Warning: file_put_contents(aCache/aDaily/post/botalkaaa/--): Failed to open stream: No such file or directory in /var/www/tgoop/post.php on line 50
Владислав in Боталка(Студенты) — Поступашки@botalkaaa P.90090
BOTALKAAA Telegram 90090
A. Еще больше контента здесь

#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
using namespace std;


vector <int> get_nech(vector <int> s, int n) {
vector<int> d1 (n);
int l=0, r=-1;
for (int i=0; i<n; ++i) {
int k = i>r ? 1 : min (d1[l+r-i], r-i+1);
while (i+k < n && i-k >= 0 && s[i+k] == s[i-k]) ++k;
d1[i] = k;
if (i+k-1 > r)
l = i-k+1, r = i+k-1;
}
return d1;
}
vector <int> get_ch(vector <int> s, int n) {
vector<int> d2 (n);
int l=0, r=-1;
for (int i=0; i<n; ++i) {
int k = i>r ? 0 : min (d2[l+r-i+1], r-i+1);
while (i+k < n && i-k-1 >= 0 && s[i+k] == s[i-k-1]) ++k;
d2[i] = k;
if (i+k-1 > r)
l = i-k, r = i+k-1;
}
return d2;
}


int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector <int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
int mx1 = 1;
int mx2 = 0;
vector <int> d1 = get_nech(a, n);
vector <int> d2 = get_ch(a, n);
for (int i = 0; i < n; ++i) {
mx1 = max(mx1, d1[i] * 2 - 1);
mx2 = max(mx2, d2[i] * 2);
}
if (mx1 == 1) {
mx1 = 0;
}
cout << max(mx1, mx2) << endl;

return 0;
}



tgoop.com/botalkaaa/90090
Create:
Last Update:

A. Еще больше контента здесь


#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
using namespace std;


vector <int> get_nech(vector <int> s, int n) {
vector<int> d1 (n);
int l=0, r=-1;
for (int i=0; i<n; ++i) {
int k = i>r ? 1 : min (d1[l+r-i], r-i+1);
while (i+k < n && i-k >= 0 && s[i+k] == s[i-k]) ++k;
d1[i] = k;
if (i+k-1 > r)
l = i-k+1, r = i+k-1;
}
return d1;
}
vector <int> get_ch(vector <int> s, int n) {
vector<int> d2 (n);
int l=0, r=-1;
for (int i=0; i<n; ++i) {
int k = i>r ? 0 : min (d2[l+r-i+1], r-i+1);
while (i+k < n && i-k-1 >= 0 && s[i+k] == s[i-k-1]) ++k;
d2[i] = k;
if (i+k-1 > r)
l = i-k, r = i+k-1;
}
return d2;
}


int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector <int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
int mx1 = 1;
int mx2 = 0;
vector <int> d1 = get_nech(a, n);
vector <int> d2 = get_ch(a, n);
for (int i = 0; i < n; ++i) {
mx1 = max(mx1, d1[i] * 2 - 1);
mx2 = max(mx2, d2[i] * 2);
}
if (mx1 == 1) {
mx1 = 0;
}
cout << max(mx1, mx2) << endl;

return 0;
}

BY Владислав in Боталка(Студенты) — Поступашки


Share with your friend now:
tgoop.com/botalkaaa/90090

View MORE
Open in Telegram


Telegram News

Date: |

According to media reports, the privacy watchdog was considering “blacklisting” some online platforms that have repeatedly posted doxxing information, with sources saying most messages were shared on Telegram. Concise Telegram iOS app: In the “Chats” tab, click the new message icon in the right upper corner. Select “New Channel.” Telegram is a leading cloud-based instant messages platform. It became popular in recent years for its privacy, speed, voice and video quality, and other unmatched features over its main competitor Whatsapp. More>>
from us


Telegram Владислав in Боталка(Студенты) — Поступашки
FROM American