Submission #1116471

#TimeUsernameProblemLanguageResultExecution timeMemory
1116471PagodePaivaPalindromic Partitions (CEOI17_palindromic)C++17
0 / 100
1 ms336 KiB
#include<bits/stdc++.h> using namespace std; void solve(){ string s; cin >> s; int n = s.size(); int l = 0, r = s.size()-1; int res = 0; for(int i = 0;i < n;i++){ string a, b; int ra = i, lb = r-(i-l+1)+1; if(lb <= ra){ res++; break; } for(int j = l;j <= i;j++){ a.push_back(s[j]); } for(int j = r;j > r-(i-l+1);j--){ b.push_back(s[j]); } reverse(b.begin(), b.end()); //cout << a << ' ' << b << '\n'; if(a.size() != b.size()) exit(0); bool aux = true; for(int j = 0;j < a.size();j++){ if(a[j] != b[j]) aux = false; } if(aux){ l = ra+1; r = lb-1; res += 2; } } cout << res << '\n'; } int main(){ int t; cin >> t; while(t--){ solve(); } }

Compilation message (stderr)

palindromic.cpp: In function 'void solve()':
palindromic.cpp:28:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for(int j = 0;j < a.size();j++){
      |                       ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...