fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. for(int i = 0; i < P; i++){
  7. for(int size = 1; size<P && i+size<P; size++){
  8. int j = i+size;//end of range
  9. //for range [i,j]
  10. dp[i][j]=MAX;
  11. for(int q = 0 q<Q; q++){
  12. if(prisoner[q]>=i && prisoner[q]<=j)//if prisoner lies in range
  13. dp[i][j]= min(dp[i][j], (j-i)+dp[i][prisoner[q]-1]+dp[prisoner[q]+1][j]);
  14. //these have definitely been calculated before
  15. }
  16. }
  17. }
  18. return 0;
  19. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:6:21: error: 'P' was not declared in this scope
  for(int i = 0; i < P; i++){
                     ^
prog.cpp:10:4: error: 'dp' was not declared in this scope
    dp[i][j]=MAX;
    ^
prog.cpp:10:13: error: 'MAX' was not declared in this scope
    dp[i][j]=MAX;
             ^
prog.cpp:11:18: error: expected ';' before 'q'
    for(int q = 0 q<Q; q++){
                  ^
prog.cpp:11:20: error: 'Q' was not declared in this scope
    for(int q = 0 q<Q; q++){
                    ^
prog.cpp:12:8: error: 'prisoner' was not declared in this scope
     if(prisoner[q]>=i && prisoner[q]<=j)//if prisoner lies in range
        ^
stdout
Standard output is empty