fork download
  1. public class BearCries {
  2. public int count(String message) {
  3. int n = message.length();
  4. final int mod = 1000 * 1000 * 1000 + 7;
  5. long[][] dp = new long[n][n];
  6. long[][] old = new long[n][n];
  7. dp[0][0] = 1L;
  8. for(int i = 0; i < n; ++i) {
  9. for(int single = 0; single < n; ++single)
  10. for(int ready = 0; ready < n; ++ready) {
  11. old[single][ready] = dp[single][ready] % mod;
  12. dp[single][ready] = 0L;
  13. }
  14. for(int single = 0; single < n; ++single)
  15. for(int ready = 0; ready < n; ++ready) {
  16. long x = old[single][ready];
  17. if(message.charAt(i) == ';') {
  18. if(single+1 < n)
  19. dp[single+1][ready] += x;
  20. if(ready > 0)
  21. dp[single][ready-1] += ready * x;
  22. }
  23. else {
  24. dp[single][ready] += ready * x;
  25. if(single > 0 && ready+1 < n)
  26. dp[single-1][ready+1] += single * x;
  27. }
  28. }
  29. }
  30. return (int) (dp[0][0] % mod);
  31. }
  32. }
  33.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: class BearCries is public, should be declared in a file named BearCries.java
public class BearCries {
       ^
1 error
stdout
Standard output is empty