Submission #1221923

#TimeUsernameProblemLanguageResultExecution timeMemory
1221923Nika533Palindromic Partitions (CEOI17_palindromic)C++20
60 / 100
10089 ms3120 KiB
#pragma GCC diagnostic warning "-std=c++11"
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
#define flush fflush(stdout)
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define pii pair<int,int>
using namespace std;
int n,m,T,k;
void test_case() {
	string s; cin>>s; n=s.size();
	int last=-1,cnt=0;
	for (int i=0; i<n/2; i++) {
		int l=last+1,r=i;
		int l1=n-r-1,r1=n-l+1;
		bool check=1;
		for (int j=l; j<=r; j++) {
			if (s[j]!=s[l1+(j-l)]) check=0;
		}
		if (check) {
			last=i; cnt+=2;
		}
	}
	if (n%2==0 && last==n/2-1) cout<<cnt<<endl;
	else cout<<cnt+1<<endl;
}
main () {
	ios :: sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	T=1; cin>>T;
	while (T--) test_case();
}

Compilation message (stderr)

palindromic.cpp:1:32: warning: '-std=c++11' is not an option that controls warnings [-Wpragmas]
    1 | #pragma GCC diagnostic warning "-std=c++11"
      |                                ^~~~~~~~~~~~
palindromic.cpp:31:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   31 | main () {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...