fork download
  1. void solve(int l ,int r,int t)
  2. {
  3.  
  4.  
  5. if(vis[l][r])return;
  6.  
  7. ret++;
  8. vis[l][r]=1;
  9.  
  10. if(t==k || l>n || r>n) return;
  11.  
  12.  
  13. int kill1=acc[r];
  14. int kill2=0;
  15.  
  16. if(p[l]>0) kill2=1;
  17. if(p[l]==100) kill2=2;
  18.  
  19. if(kill1==0 && kill2==0) return;
  20.  
  21. if(kill1==0 && kill2==1)
  22. {
  23. solve(l,r+1,t+1);
  24. }
  25.  
  26. if(kill1==0 && kill2==2)
  27. {
  28. solve(l,r+1,t+1);
  29. }
  30.  
  31. if(kill1==1 && kill2==0)
  32. {
  33. solve(r,r+1,t+1);
  34. }
  35.  
  36. if(kill1==1 && kill2==1)
  37. {
  38. solve(r,r+1,t+1);
  39. solve(l,r+1,t+1);
  40. solve(r+1,r+2,t+1);
  41. }
  42.  
  43. if(kill1==1 && kill2==2)
  44. {
  45. solve(l,r+1,t+1);
  46. solve(r+1,r+2,t+1);
  47. }
  48.  
  49. if(kill1==2 && kill2==0)
  50. {
  51. solve(r,r+1,t+1);
  52. }
  53.  
  54. if(kill1==2 && kill2==1)
  55. {
  56. solve(r,r+1,t+1);
  57. solve(r+1,r+2,t+1);
  58. }
  59.  
  60. if(kill1==2 && kill2==2)
  61. {
  62. solve(r+1,r+2,t+1);
  63. }
  64.  
  65.  
  66. }
  67.  
  68.  
  69.  
  70. struct node
  71. {
  72. int l ,r,t;
  73. node(int l=0,int r=0,int t=0):l(l),r(r),t(t){};
  74. };
  75. void bfs()
  76. {
  77. queue<node> q;
  78. q.push(node(1,2,0));
  79. while(q.size())
  80. {
  81.  
  82. node cur=q.front();
  83. q.pop();
  84. int l=cur.l;
  85. int r=cur.r;
  86. int t=cur.t;
  87.  
  88. if(vis[l][r])continue;
  89.  
  90. ret++;
  91. vis[l][r]=1;
  92.  
  93. if(t==k || l>n || r>n) continue;
  94.  
  95.  
  96. int kill1=acc[r];
  97. int kill2=0;
  98.  
  99. if(p[l]>0) kill2=1;
  100. if(p[l]==100) kill2=2;
  101.  
  102. if(kill1==0 && kill2==0) continue;
  103.  
  104. if(kill1==0 && kill2==1)
  105. {
  106. q.push(node(l,r+1,t+1));
  107. }
  108.  
  109. if(kill1==0 && kill2==2)
  110. {
  111. q.push(node(l,r+1,t+1));
  112. }
  113.  
  114. if(kill1==1 && kill2==0)
  115. {
  116. q.push(node(r,r+1,t+1));
  117. }
  118.  
  119. if(kill1==1 && kill2==1)
  120. {
  121. q.push(node(r,r+1,t+1));
  122. q.push(node(l,r+1,t+1));
  123. q.push(node(r+1,r+2,t+1));
  124. }
  125.  
  126. if(kill1==1 && kill2==2)
  127. {
  128. q.push(node(l,r+1,t+1));
  129. q.push(node(r+1,r+2,t+1));
  130. }
  131.  
  132. if(kill1==2 && kill2==0)
  133. {
  134. q.push(node(r,r+1,t+1));
  135. }
  136.  
  137. if(kill1==2 && kill2==1)
  138. {
  139. q.push(node(r,r+1,t+1));
  140. q.push(node(r+1,r+2,t+1));
  141. }
  142.  
  143. if(kill1==2 && kill2==2)
  144. {
  145. q.push(node(r+1,r+2,t+1));
  146. }
  147. }
  148.  
  149. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘void solve(int, int, int)’:
prog.cpp:5:8: error: ‘vis’ was not declared in this scope
     if(vis[l][r])return;
        ^
prog.cpp:7:5: error: ‘ret’ was not declared in this scope
     ret++;
     ^
prog.cpp:8:5: error: ‘vis’ was not declared in this scope
     vis[l][r]=1;
     ^
prog.cpp:10:11: error: ‘k’ was not declared in this scope
     if(t==k || l>n || r>n) return;
           ^
prog.cpp:10:18: error: ‘n’ was not declared in this scope
     if(t==k || l>n || r>n) return;
                  ^
prog.cpp:13:15: error: ‘acc’ was not declared in this scope
     int kill1=acc[r];
               ^
prog.cpp:16:8: error: ‘p’ was not declared in this scope
     if(p[l]>0) kill2=1;
        ^
prog.cpp:17:8: error: ‘p’ was not declared in this scope
     if(p[l]==100) kill2=2;
        ^
prog.cpp: In function ‘void bfs()’:
prog.cpp:77:3: error: ‘queue’ was not declared in this scope
   queue<node> q;
   ^
prog.cpp:77:13: error: expected primary-expression before ‘>’ token
   queue<node> q;
             ^
prog.cpp:77:15: error: ‘q’ was not declared in this scope
   queue<node> q;
               ^
prog.cpp:88:8: error: ‘vis’ was not declared in this scope
     if(vis[l][r])continue;
        ^
prog.cpp:90:5: error: ‘ret’ was not declared in this scope
     ret++;
     ^
prog.cpp:91:5: error: ‘vis’ was not declared in this scope
     vis[l][r]=1;
     ^
prog.cpp:93:11: error: ‘k’ was not declared in this scope
     if(t==k || l>n || r>n) continue;
           ^
prog.cpp:93:18: error: ‘n’ was not declared in this scope
     if(t==k || l>n || r>n) continue;
                  ^
prog.cpp:96:15: error: ‘acc’ was not declared in this scope
     int kill1=acc[r];
               ^
prog.cpp:99:8: error: ‘p’ was not declared in this scope
     if(p[l]>0) kill2=1;
        ^
prog.cpp:100:8: error: ‘p’ was not declared in this scope
     if(p[l]==100) kill2=2;
        ^
stdout
Standard output is empty