fork download
  1. typedef array<ld, 3> P;
  2. ld func(P p);
  3. pair<ld, P> hillClimb(P start, ld width, int max_fail) {
  4. pair<ld, P> cur(func(start), start);
  5. int failure;
  6. for (ld jmp = width; jmp > 1e-20; jmp /= 2) {
  7. failure = 0;
  8. while(true){
  9. rep(dx,-1,2) rep(dy,-1,2) rep(dz, -1, 2){
  10. if(!dx && !dy && !dz) continue;
  11. P p = cur.second;
  12. p[0] += dx*jmp;
  13. p[1] += dy*jmp;
  14. p[2] += dz*jmp;
  15. pair<ld, P> tmp = make_pair(func(p), p);
  16. if(tmp.X < cur.X) cur = tmp, failure = 0;
  17. else if(failure >= max_fail) goto NEXT_JMP;
  18. else failure++;
  19. }
  20. }
  21. NEXT_JMP:;
  22. }
  23. return cur;
  24. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:9: error: ‘array’ does not name a type
 typedef array<ld, 3> P;
         ^~~~~
prog.cpp:2:1: error: ‘ld’ does not name a type
 ld func(P p);
 ^~
prog.cpp:3:1: error: ‘pair’ does not name a type
 pair<ld, P> hillClimb(P start, ld width, int max_fail) {
 ^~~~
stdout
Standard output is empty