Submission #1134770

#TimeUsernameProblemLanguageResultExecution timeMemory
1134770vyaductPalindromic Partitions (CEOI17_palindromic)C++20
0 / 100
2 ms320 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] + b; if (a == b) { ans+=2; search(i+1, j-1); return; } 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)

palindromic.cpp: In function 'void setIo(std::string, std::string)':
palindromic.cpp:7:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     freopen(in.c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
palindromic.cpp:8:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     freopen(out.c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...