fork download
  1. // Errichto
  2.  
  3. // Div2-Easy
  4. public class BearSong {
  5. public int countRareNotes(int[] notes) {
  6. final int lim = 1005;
  7. int cnt[] = new int[lim];
  8. int n = notes.length;
  9. for(int i = 0; i < n; ++i)
  10. cnt[notes[i]]++;
  11. int ans = 0;
  12. for(int i = 0; i < lim; ++i)
  13. if(cnt[i] == 1)
  14. ++ans;
  15. return ans;
  16. }
  17. }
  18.  
  19.  
  20. // Div2-Med
  21. public class BearSlowlySorts {
  22. boolean isSorted(int[] w) {
  23. for(int i = 0; i < w.length - 1; ++i)
  24. if(w[i] > w[i+1]) return false;
  25. return true;
  26. }
  27.  
  28. public int minMoves(int[] w) {
  29. int n = w.length;
  30. int memo[] = new int[n];
  31. for(int i = 0; i < n; ++i) memo[i] = w[i];
  32. int ans = -1;
  33. for(int i = 0; i <= 1; ++i) {
  34. for(int j = 0; j < n; ++j) w[j] = memo[j];
  35. int which = i;
  36. int a = 0;
  37. while(!isSorted(w)) {
  38. if(which == 1) Arrays.sort(w, 0, n - 1);
  39. else Arrays.sort(w, 1, n);
  40. ++a;
  41. which = 1 - which;
  42. }
  43. if(a < ans || ans == -1) ans = a;
  44. }
  45. return ans;
  46. }
  47. }
  48.  
  49. // Div2-Hard
  50. public class BearPermutations2 {
  51. public int getSum(int N, int mod) {
  52. long bin[][] = new long[N+1][N+1];
  53. long fac[] = new long[N+1];
  54. fac[0] = 1;
  55. for(int i = 0; i <= N; ++i) {
  56. if(i > 0) fac[i] = fac[i-1] * i % mod;
  57. bin[i][0] = 1;
  58. for(int j = 1; j <= i; ++j)
  59. bin[i][j] = (bin[i-1][j-1] + bin[i-1][j]) % mod;
  60. }
  61.  
  62.  
  63. long dp[] = new long[N+1];
  64.  
  65. for(int n = 1; n <= N; ++n) {
  66. // where the smallest/biggest number goes
  67. for(int where = 1; where <= n; ++where) {
  68. if(where == 1 || where == n) {
  69. dp[n] += dp[n-1];
  70. dp[n] %= mod;
  71. }
  72. else {
  73. int n1 = where - 1;
  74. int n2 = n - where;
  75. for(int rep = 0; rep <= 1; ++rep) {
  76. int tmp = n1; n1 = n2; n2 = tmp;
  77. dp[n] += dp[n1] * bin[n1+n2][n1] % mod * fac[n2];
  78. dp[n] %= mod;
  79. long s = n1 * (n1 + 1) / 2;
  80. dp[n] += s * bin[n1+n2][n1] % mod * fac[n2] % mod * fac[n1-1];
  81. dp[n] %= mod;
  82. }
  83. }
  84. }
  85. }
  86. return (int) dp[N];
  87. }
  88. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:4: error: class BearSong is public, should be declared in a file named BearSong.java
public class BearSong {
       ^
Main.java:21: error: class BearSlowlySorts is public, should be declared in a file named BearSlowlySorts.java
public class BearSlowlySorts {
       ^
Main.java:50: error: class BearPermutations2 is public, should be declared in a file named BearPermutations2.java
public class BearPermutations2 {
       ^
Main.java:38: error: cannot find symbol
                if(which == 1) Arrays.sort(w, 0, n - 1);
                               ^
  symbol:   variable Arrays
  location: class BearSlowlySorts
Main.java:39: error: cannot find symbol
                else Arrays.sort(w, 1, n);
                     ^
  symbol:   variable Arrays
  location: class BearSlowlySorts
5 errors
stdout
Standard output is empty