From 60c24a78c1d5303b2d6d21e7918e1713d6814851 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sun, 22 May 2022 22:55:54 +0800 Subject: [PATCH] A - Palindromic Indices https://codeforces.com/contest/1682/submission/158020857 --- Codeforces/1682/A/A.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Codeforces/1682/A/A.cpp diff --git a/Codeforces/1682/A/A.cpp b/Codeforces/1682/A/A.cpp new file mode 100644 index 00000000..e46a05cc --- /dev/null +++ b/Codeforces/1682/A/A.cpp @@ -0,0 +1,30 @@ +#include +#include + +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; +}