Submission #1017372

# Submission time Handle Problem Language Result Execution time Memory
1017372 2024-07-09T07:38:30 Z cnn008 Palindromic Partitions (CEOI17_palindromic) C++17
60 / 100
10000 ms 5440 KB
#include "bits/stdc++.h"
using namespace std;

#ifdef N_N_C
#include "debug.h"
#else
#define cebug(...) "Arya"
#endif

#define ll long long

const int N=1e6+5;
const int mod=1e9+7;

int n,ans;
string s;
bool cmp(string &a, string &b){
	for(int i=0; i<(int)a.size(); i++) if(a[i]!=b[i]) return 0;
	return 1;
}
void sol(){
	ans=0;
	cin>>s;
	n=(int)s.size();
	s=' '+s;
	int l=1,r=n;
	while(l<=r){
		int _l=l,_r=r,f=0;
		string cur,revcur;
		while(_l<_r){
			cur.push_back(s[_l++]);
			revcur.push_back(s[_r--]);
			reverse(revcur.begin(),revcur.end());
			if(cmp(cur,revcur)){
				ans+=2;
				f=1;
				break;
			}
			reverse(revcur.begin(),revcur.end());
		}
		if(!f){
			ans++;
			break;
		}
		l=_l;
		r=_r;
	}
	cout<<ans<<"\n";
}
signed main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen(".inp", "r", stdin);
    // freopen(".out", "w", stdout);
    int tt=1;
    cin>>tt; 
    while(tt--){
    	sol();
    }
    cerr << "\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 70 ms 348 KB Output is correct
11 Correct 60 ms 536 KB Output is correct
12 Correct 4 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 70 ms 348 KB Output is correct
11 Correct 60 ms 536 KB Output is correct
12 Correct 4 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Execution timed out 10026 ms 5440 KB Time limit exceeded
15 Halted 0 ms 0 KB -