fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int p[200]; // prisoners to be released.
  5. map<pair<int, int>, int> dp;
  6.  
  7. // Finds the minimum amount of gold needed,
  8. // if we only consider the cells from a to b, inclusive.
  9. int Solve(int a, int b) {
  10. // First, look up the cache to see if the
  11. // result is computed before.
  12. pair<int, int> pr(a, b);
  13. if(mp.find(pr) != mp.end()) return mp[pr];
  14.  
  15. // Start the computation.
  16. int r = 0;
  17. for(int i=0; i<Q; i++) {
  18. if(p[i] >= a && p[i] <= b) {
  19. int tmp = (b-a) + Solve(a, p[i]-1) + Solve(p[i]+1, b);
  20. if (!r || tmp<r) r=tmp;
  21. }
  22. }
  23. mp[pr]=r;
  24. return r;
  25. }
  26.  
  27. int main() {
  28. // your code goes here
  29. ans = solve(0,p-1);
  30. //code taken from codejam editorial
  31. return 0;
  32. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:5:1: error: 'map' does not name a type
 map<pair<int, int>, int> dp;
 ^
prog.cpp: In function 'int Solve(int, int)':
prog.cpp:13:6: error: 'mp' was not declared in this scope
   if(mp.find(pr) != mp.end()) return mp[pr];
      ^
prog.cpp:17:18: error: 'Q' was not declared in this scope
   for(int i=0; i<Q; i++) {
                  ^
prog.cpp:23:3: error: 'mp' was not declared in this scope
   mp[pr]=r;
   ^
prog.cpp: In function 'int main()':
prog.cpp:29:2: error: 'ans' was not declared in this scope
  ans = solve(0,p-1);
  ^
prog.cpp:29:19: error: 'solve' was not declared in this scope
  ans = solve(0,p-1);
                   ^
stdout
Standard output is empty