This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///Phạm Nguyễn Tuấn Hoàng///
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define repd(i,a,b) for(int i = (a);i >= (b);i--)
#define F first
#define S second
#define PB push_back
#define Task ""
using namespace std;
//template <class T> inline read(T &a){a = 0;char c;bool nega = 0;while(!isdigit(c = getchar()) && c != '-');if(c == '-') nega = 1,c = getchar();a = c - 48;while(isdigit(c = getchar()))a = a * 10 + c - 48;if(nega) a = -a;}
//template <class T> inline writep(T a){if(a > 9) writep(a / 10);putchar(a % 10 + 48);}
//template <class T> inline write(T a){if(a < 0) putchar('-'),a = -a;writep(a);putchar(' ');}
//template <class T> inline writeln(T a){write(a);putchar('\n');}
int main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// freopen(Task".inp","r",stdin);
// freopen(Task".out","w",stdout);
int T;
cin >> T;
while(T--)
{
string s;
cin >> s;
int n = s.size();
s = ' ' + s;
int End = n,Begin = 1,cnt = 0,last = 0;
vector<int> df(27),ds(27);
while(End > Begin)
{
bool check = 1;
df[s[End] -'a']++;
ds[s[Begin] - 'a']++;
rep(i,0,'z' - 'a') if(df[i] != ds[i]) check = 0;
if(check)
{
cnt += 2;
rep(i,0,'z' - 'a') df[i] = ds[i] = 0;
last = End;
}
End--,Begin++;
}
cout << cnt + (last != Begin) << '\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |