Submission #545678

#TimeUsernameProblemLanguageResultExecution timeMemory
545678Ai7081Palindromic Partitions (CEOI17_palindromic)C++17
15 / 100
1 ms320 KiB
#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)

palindromic.cpp: In function 'int main()':
palindromic.cpp:15:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |         for (int i=0; i<s.size()/2; i++) {
      |                       ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...