fork download
  1. // Errichto - easy
  2.  
  3. public static double minTime(int[] x, int[] y) {
  4. int n = x.length;
  5. int M = 1 << n;
  6. double dp[][] = new double[M][n];
  7. for(int S = 0; S < M; ++S)
  8. for(int A = 0; A < M; ++A)
  9. if((S | A) == S)
  10. for(int a = 0; a < n; ++a)
  11. for(int b = 0; b < n; ++b)
  12. if((A & (1 << a)) > 0)
  13. if((S & (1 << b)) > 0 && (A & (1 << b)) == 0) {
  14. double dist = Math.sqrt(Math.pow(x[a]-x[b],2) + Math.pow(y[a]-y[b],2));
  15. double maybe = dist + Math.max(dp[A][a],dp[S-A][b]);
  16. if(dp[S][a] < 0.1 || dp[S][a] > maybe)
  17. dp[S][a] = maybe;
  18. }
  19. return dp[M-1][0];
  20. }
  21.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:3: error: class, interface, or enum expected
    public static double minTime(int[] x, int[] y) {
                  ^
Main.java:5: error: class, interface, or enum expected
        int M = 1 << n;
        ^
Main.java:6: error: class, interface, or enum expected
        double dp[][] = new double[M][n];
        ^
Main.java:7: error: class, interface, or enum expected
        for(int S = 0; S < M; ++S)
        ^
Main.java:7: error: class, interface, or enum expected
        for(int S = 0; S < M; ++S)
                       ^
Main.java:7: error: class, interface, or enum expected
        for(int S = 0; S < M; ++S)
                              ^
Main.java:8: error: class, interface, or enum expected
         for(int A = 0; A < M; ++A)
                        ^
Main.java:8: error: class, interface, or enum expected
         for(int A = 0; A < M; ++A)
                               ^
Main.java:10: error: class, interface, or enum expected
           for(int a = 0; a < n; ++a)
                          ^
Main.java:10: error: class, interface, or enum expected
           for(int a = 0; a < n; ++a)
                                 ^
Main.java:11: error: class, interface, or enum expected
            for(int b = 0; b < n; ++b)
                           ^
Main.java:11: error: class, interface, or enum expected
            for(int b = 0; b < n; ++b)
                                  ^
Main.java:15: error: class, interface, or enum expected
               double maybe = dist + Math.max(dp[A][a],dp[S-A][b]);
               ^
Main.java:16: error: class, interface, or enum expected
               if(dp[S][a] < 0.1 || dp[S][a] > maybe)
               ^
Main.java:18: error: class, interface, or enum expected
              }
              ^
Main.java:20: error: class, interface, or enum expected
    }
    ^
16 errors
stdout
Standard output is empty