dh-winternagi 님의 블로그
(25501) 재귀의 귀재 본문
https://www.acmicpc.net/problem/25501
단계별로 풀어보기
19단계(재귀) 3번째

#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
string s;
int cnt;
auto pal= [&](auto& self, int l, int r) -> int {
cnt++;
if(l>=r) return 1;
else if(s[l]!=s[r]) return 0;
else return self(self, l+1, r-1);
};
int T;
cin >> T;
while(T--){
string S;
cin >> S;
s= S;
cnt= 0;
cout << pal(pal, 0, s.length()-1) << " " << cnt << "\n";
}
return 0;
}'백준 (C++) > Solve' 카테고리의 다른 글
| (4779) 칸토어 집합 (0) | 2026.04.17 |
|---|---|
| (24060) 알고리즘 수업 - 병합 정렬 1 (0) | 2026.04.17 |
| (10870) 피보나치 수 5 (0) | 2026.04.16 |
| (27433) 팩토리얼 2 (0) | 2026.04.16 |
| (20920) 영단어 암기는 괴로워 (0) | 2026.04.16 |
