fork download
  1. public class Flee {
  2.  
  3. boolean check(int[] x, int[] y, double r)
  4. {
  5. int n = x.length;
  6. for(int i = 0; i < n; i++)
  7. if(x[i]*x[i] + y[i]*y[i] <= r*r)
  8. return true;
  9. boolean linked[][] = new boolean[n][n];
  10. for(int i = 0; i < n; i++)
  11. for(int j = 0; j < n; j++)
  12. if((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) <= 4*r*r)
  13. linked[i][j] = true;
  14. for(int start = 0; start < n; start++)
  15. {
  16. double[] maxVal = new double[n];
  17. for(int i = 0; i < n; i++)
  18. maxVal[i] = -1000;
  19. maxVal[start] = 0;
  20. for(int iteration = 1; iteration <= n; iteration ++)
  21. {
  22. for(int i = 0; i < n; i++)
  23. for(int j = 0; j < n; j++)
  24. if(linked[i][j])
  25. {
  26. double delta = Math.atan2(y[j], x[j]) - Math.atan2(y[i], x[i]);
  27. if(Math.abs(delta + Math.PI * 2) < Math.abs(delta))
  28. delta = delta + Math.PI * 2;
  29. else if(Math.abs(delta - Math.PI*2) < Math.abs(delta))
  30. delta = delta - Math.PI * 2;
  31. maxVal[j] = Math.max(maxVal[j], maxVal[i] + delta);
  32. }
  33. }
  34. if(maxVal[start] >= 2 * Math.PI - 1e-9)
  35. return true;
  36. }
  37. return false;
  38. }
  39.  
  40. public double maximalSafetyLevel(int[] x, int[] y)
  41. {
  42. double L = 0, R = 2000, M = 0;
  43. for(int iteration = 1; iteration <= 100; iteration ++)
  44. {
  45. M = (L + R) / 2;
  46. if(check(x, y, M))
  47. R = M;
  48. else
  49. L = M;
  50. }
  51. return M;
  52. }
  53. }
  54.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: class Flee is public, should be declared in a file named Flee.java
public class Flee {
       ^
1 error
stdout
Standard output is empty