fork(1) download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. class FindStringEasy
  6. {
  7. public:
  8. string ans = "" ;
  9. int a ;
  10. int cnt(string s)
  11. {
  12. int n = s.size() ;
  13. int cnt = 0 ;
  14. for(int i = 0 ; i < n ; ++i)
  15. {
  16. string s2 = "" ;
  17. for(int j = i ; j < n ; ++j)
  18. {
  19. s2 += s[j] ;
  20. string s3 = s2 ;
  21. reverse(s3.begin() , s3.end());
  22. if(s2 == s3)
  23. cnt++;
  24. }
  25. }
  26. return cnt ;
  27. }
  28. void solve(string s)
  29. {
  30. if(ans.size() > 0)
  31. return ;
  32. int x = cnt(s) ;
  33. if(x == a)
  34. {
  35. ans = s ;
  36. return ;
  37. }
  38. if(x > a)
  39. return ;
  40. solve(s + 'a');
  41. solve(s + 'b');
  42. }
  43. string withPalindromicSubstrings(int n)
  44. {
  45. a = n ;
  46. solve("");
  47. return ans ;
  48. }
  49. };
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty