0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-25 17:32:01 +00:00

A - Palindromic Indices

https://codeforces.com/contest/1682/submission/158020857
This commit is contained in:
Baoshuo Ren 2022-05-22 22:55:54 +08:00
parent 74ab0166cc
commit 60c24a78c1
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

30
Codeforces/1682/A/A.cpp Normal file
View File

@ -0,0 +1,30 @@
#include <iostream>
#include <string>
using std::cin;
using std::cout;
const char endl = '\n';
int t, n;
std::string s;
int main() {
std::ios::sync_with_stdio(false);
cin >> t;
while (t--) {
cin >> n >> s;
s = ' ' + s;
int mid = n & 1 ? n / 2 : n / 2 - 1;
int ans = 2 - (n & 1);
for (int i = mid; i && s[i] == s[i + 1]; i--) ans += 2;
cout << ans << endl;
}
return 0;
}