fork download
  1. #pragma GCC optimize ("Ofast")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. #define main dummy_main
  5. int main(){
  6. return 0;
  7. }
  8. #undef main
  9. #define TreeNode dummy_TreeNode
  10. struct TreeNode{
  11. }
  12. ;
  13. #undef TreeNode
  14. int solve(TreeNode *n, int b1, int b2){
  15. int res = 0;
  16. if(n==NULL){
  17. return res;
  18. }
  19. if(b2==0){
  20. res += n->val;
  21. }
  22. res += solve(n->left, n->val%2, b1);
  23. res += solve(n->right, n->val%2, b1);
  24. return res;
  25. }
  26. class Solution{
  27. public:
  28. int sumEvenGrandparent(TreeNode* root){
  29. return solve(root, 1, 1);
  30. }
  31. }
  32. ;
  33. // cLay varsion 20200112-1
  34.  
  35. // --- original code ---
  36. // #define main dummy_main
  37. // {}
  38. // #undef main
  39. //
  40. // #define TreeNode dummy_TreeNode
  41. // struct TreeNode {};
  42. // #undef TreeNode
  43. //
  44. // int solve(TreeNode *n, int b1, int b2){
  45. // int res = 0;
  46. // if(n==NULL) return res;
  47. // if(b2==0) res += n->val;
  48. // res += solve(n->left, n->val%2, b1);
  49. // res += solve(n->right, n->val%2, b1);
  50. // return res;
  51. // }
  52. //
  53. // class Solution {
  54. // public:
  55. // int sumEvenGrandparent(TreeNode* root) {
  56. // return solve(root, 1, 1);
  57. // }
  58. // };
  59. //
  60.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:14:11: error: ‘TreeNode’ was not declared in this scope
 int solve(TreeNode *n, int b1, int b2){
           ^~~~~~~~
prog.cpp:14:11: note: suggested alternative: ‘remove’
 int solve(TreeNode *n, int b1, int b2){
           ^~~~~~~~
           remove
prog.cpp:14:21: error: ‘n’ was not declared in this scope
 int solve(TreeNode *n, int b1, int b2){
                     ^
prog.cpp:14:21: note: suggested alternative: ‘yn’
 int solve(TreeNode *n, int b1, int b2){
                     ^
                     yn
prog.cpp:14:24: error: expected primary-expression before ‘int’
 int solve(TreeNode *n, int b1, int b2){
                        ^~~
prog.cpp:14:32: error: expected primary-expression before ‘int’
 int solve(TreeNode *n, int b1, int b2){
                                ^~~
prog.cpp:14:38: error: expression list treated as compound expression in initializer [-fpermissive]
 int solve(TreeNode *n, int b1, int b2){
                                      ^
prog.cpp:28:26: error: ‘TreeNode’ has not been declared
   int sumEvenGrandparent(TreeNode* root){
                          ^~~~~~~~
prog.cpp: In member function ‘int Solution::sumEvenGrandparent(int*)’:
prog.cpp:29:28: error: ‘solve’ cannot be used as a function
     return solve(root, 1, 1);
                            ^
stdout
Standard output is empty