# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1134762 | vyaduct | Palindromic Partitions (CEOI17_palindromic) | C++20 | 1 ms | 320 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void setIo(string in="", string out=""){
if (!in.empty() && !out.empty()){
freopen(in.c_str(), "r", stdin);
freopen(out.c_str(), "w", stdout);
}
ios::sync_with_stdio(false);
cin.tie(0);
}
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define vt vector
#define pb push_back
#define F first
#define S second
string s; int ans;
void search(int i, int j){
string a="", b="";
while(i < j){
a += s[i], b += s[j];
reverse(all(b));
if (a == b) {
ans++;
search(i+1, j-1);
}
reverse(all(b));
i++; j--;
}
ans++;
return;
}
void solve(){
cin>>s;
ans = 0;
search(0, sz(s)-1);
cout << ans << "\n";
}
int main() {
setIo();
// setIo("input.txt", "output.txt");
int tt; cin>>tt; while(tt--) solve();
// solve();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |