제출 #939036

#제출 시각아이디문제언어결과실행 시간메모리
939036huyboyPalindromic Partitions (CEOI17_palindromic)C++17
0 / 100
10014 ms596 KiB
#include "bits/stdc++.h" #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define int long long #define ff first #define ss second #define pb push_back #define all(x) x.begin(),x.end() #define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> const int INF = 1e18; void solve(){ string s; cin >> s; int n = s.size(); int ans = 0; for(int mask = 0;mask < (1 << n);mask++){ string h = ""; for(int i = 0;i < n;i++){ h += (mask >> i & 1) + '0'; } string res = ""; char lst = '-'; vector<string> v; int cnt = 1; for(int i = 0;i < n;i++){ if(h[i] != lst){ if(lst == '-'){ } else{ cnt++; v.pb(res); res = ""; } } res += s[i]; lst = h[i]; } v.pb(res); vector<string> z = v; reverse(all(z)); if(z == v){ ans = max(ans,cnt); } } cout << ans << "\n"; } //(h[i] - h[j]) * (h[i] - h[j]) + pref[i] - pref[j + 1] signed main(){ ios_base::sync_with_stdio(0); cin.tie(0),cout.tie(0); int t = 1; cin >> t; while(t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...