Submission #1322723

#TimeUsernameProblemLanguageResultExecution timeMemory
1322723JohanPalindromic Partitions (CEOI17_palindromic)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while(t--){ string s; cin >> s; int cnt = 0, n = (int)s.size(), lst = 0; s = '#' + s; for(int i = 1; i <= n / 2; i++){ // string y = "", x = ""; for(int j = lst + 1; j <= i; j++)x += s[j]; for(int j = (n - lst + 1) - (i - lst); j <= n - lst; j++)y += s[j]; // cout << i << "->" << x << ',' << y << endl; if(x == y){ lst = i; cnt += 2; } } cout << cnt + 1 << endl; } }

Compilation message (stderr)

palindromic.cpp: In function 'int main()':
palindromic.cpp:17:40: error: 'x' was not declared in this scope
   17 |       for(int j = lst + 1; j <= i; j++)x += s[j];
      |                                        ^
palindromic.cpp:18:64: error: 'y' was not declared in this scope
   18 |       for(int j = (n - lst + 1) - (i - lst); j <= n - lst; j++)y += s[j];
      |                                                                ^
palindromic.cpp:20:10: error: 'x' was not declared in this scope
   20 |       if(x == y){
      |          ^
palindromic.cpp:20:15: error: 'y' was not declared in this scope
   20 |       if(x == y){
      |               ^