# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
545678 | Ai7081 | Palindromic Partitions (CEOI17_palindromic) | C++17 | 1 ms | 320 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int t, out;
string s;
stack<char> st;
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> t;
while (t--) {
out = 0;
while (!st.empty()) st.pop();
cin >> s;
for (int i=0; i<s.size()/2; i++) {
if (st.empty()) st.push(s[i]);
else {
if (st.top() == s[i]) st.pop();
else st.push(s[i]);
}
if (st.top() == s[s.size()-1-i]) st.pop();
else st.push(s[s.size()-1-i]);
out += 2*st.empty();
}
if (s.size()%2 || !st.empty()) out++;
cout << out << endl;
}
return 0;
}
Compilation message (stderr)
# | 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... |