fork(5) download
  1. double polygonDiameter(vector<PT> &p)
  2. {
  3. int n=SZ(p);
  4. if(n<2) return 0;
  5. else if(n==2) return distPoint(p[0],p[1]);//distance between two points
  6. else
  7. {
  8. int i=n-1,j=0,k=1;
  9. double res=0;
  10. while(abs(cross(p[j]-p[i],p[k+1]-p[i]) >
  11. abs(cross(p[j]-p[i],p[k]-p[i]))))
  12. {
  13. k++;
  14. }
  15. i=0,j=k;
  16. while(i<=k && j<n)
  17. {
  18. res=max(distPoint(p[i],p[j]),res);
  19. while(j<n-1 && abs(cross(p[i+1]-p[i],p[j+1]-p[i]) >
  20. abs(cross(p[i+1]-p[i],p[j]-p[i]))))
  21. {
  22. j++;
  23. res=max(distPoint(p[i],p[j]),res);
  24. }
  25. i++;
  26. }
  27. return res;
  28. }
  29. }
  30.  
  31. int main()
  32. {
  33. #ifdef MAHDI
  34. // Read;
  35. // Write;
  36. #endif // MAHDI
  37. vector<PT> poly,cpoly;PT a;
  38. int n;
  39. sf("%d",&n);
  40. for(int i=0;i<n;i++)
  41. {
  42. a.input();
  43. poly.psb(a);
  44. }
  45. ConvexHull(poly,cpoly);
  46. pf("%.12f\n",polygonDiameter(cpoly));
  47. return 0;
  48. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:24: error: 'vector' was not declared in this scope
 double polygonDiameter(vector<PT> &p)
                        ^
prog.cpp:1:31: error: 'PT' was not declared in this scope
 double polygonDiameter(vector<PT> &p)
                               ^
prog.cpp:1:36: error: 'p' was not declared in this scope
 double polygonDiameter(vector<PT> &p)
                                    ^
prog.cpp:2:1: error: expected ',' or ';' before '{' token
 {
 ^
stdout
Standard output is empty