제출 #1134762

#제출 시각아이디문제언어결과실행 시간메모리
1134762vyaductPalindromic Partitions (CEOI17_palindromic)C++20
0 / 100
1 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];
    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;
} 

컴파일 시 표준 에러 (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...