fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class FloodIsolation
  9. {
  10. private final static int nEdges = 6;
  11. private final int numberOfCells;
  12. private boolean[] floodedCells;
  13. private boolean[] floodedCellsTimeInterval;
  14. private int[] neighborIds;
  15. private double[] valueOfCellIds;
  16. private double[] h;
  17. private double[] h0;
  18. private double[] vU;
  19. private double[] vV;
  20. private double[] vUh;
  21. private double[] vVh;
  22. private double[] vUh0;
  23. private double[] vVh0;
  24. private double[] ghh;
  25. private double[] sfx;
  26. private double[] sfy;
  27. private double[] qInflow;
  28. private double[] qStartTime;
  29. private double[] qEndTime;
  30. private double[] qIn;
  31. private int[] lowerFloorCells;
  32. private boolean[] flagInterface;
  33. private int[] typeInterface;
  34. private double[] cellLocationX;
  35. private double[] cellLocationY;
  36. private double[] cellLocationZ;
  37. private int[] levelOfCell;
  38.  
  39. public static void main (String[] args) throws java.lang.Exception
  40. {
  41. FloodIsolation isolation = new FloodIsolation();
  42. long start = System.currentTimeMillis();
  43. for (int i = 0; i < 400; i++) {
  44. if(i % 100 == 0) {
  45. System.out.println(i);
  46. }
  47. isolation.isUpdateNeeded();
  48. }
  49. long stop = System.currentTimeMillis();
  50. System.out.println("Time: " + (stop - start));
  51. }
  52.  
  53. public FloodIsolation() {
  54. this.numberOfCells = 20000;
  55. this.h = new double[numberOfCells];
  56. this.floodedCells = new boolean[numberOfCells];
  57. this.floodedCellsTimeInterval = new boolean[numberOfCells];
  58. this.qInflow = new double[numberOfCells];
  59. this.qStartTime = new double[numberOfCells];
  60. this.qEndTime = new double[numberOfCells];
  61. this.lowerFloorCells = new int[numberOfCells];
  62. this.cellLocationX = new double[numberOfCells];
  63. this.cellLocationY = new double[numberOfCells];
  64. this.cellLocationZ = new double[numberOfCells];
  65. this.levelOfCell = new int[numberOfCells];
  66. this.valueOfCellIds = new double[numberOfCells];
  67. this.h0 = new double[numberOfCells];
  68. this.vU = new double[numberOfCells];
  69. this.vV = new double[numberOfCells];
  70. this.vUh = new double[numberOfCells];
  71. this.vVh = new double[numberOfCells];
  72. this.vUh0 = new double[numberOfCells];
  73. this.vVh0 = new double[numberOfCells];
  74. this.ghh = new double[numberOfCells];
  75. this.sfx = new double[numberOfCells];
  76. this.sfy = new double[numberOfCells];
  77. this.qIn = new double[numberOfCells];
  78. this.neighborIds = new int[numberOfCells * nEdges];
  79. this.flagInterface = new boolean[numberOfCells * nEdges];
  80. this.typeInterface = new int[numberOfCells * nEdges];
  81. }
  82.  
  83. public void isUpdateNeeded() {
  84. for (int i = 0; i < numberOfCells; ++i) {
  85. h[i] = h[i] + 1;
  86. floodedCells[i] = !floodedCells[i];
  87. floodedCellsTimeInterval[i] = !floodedCellsTimeInterval[i];
  88. qInflow[i] = qInflow[i] + 1;
  89. qStartTime[i] = qStartTime[i] + 1;
  90. qEndTime[i] = qEndTime[i] + 1;
  91. lowerFloorCells[i] = lowerFloorCells[i] + 1;
  92. cellLocationX[i] = cellLocationX[i] + 1;
  93. cellLocationY[i] = cellLocationY[i] + 1;
  94. cellLocationZ[i] = cellLocationZ[i] + 1;
  95. levelOfCell[i] = levelOfCell[i] + 1;
  96. valueOfCellIds[i] = valueOfCellIds[i] + 1;
  97. h0[i] = h0[i] + 1;
  98. vU[i] = vU[i] + 1;
  99. vV[i] = vV[i] + 1;
  100. vUh[i] = vUh[i] + 1;
  101. vVh[i] = vVh[i] + 1;
  102. vUh0[i] = vUh0[i] + 1;
  103. vVh0[i] = vVh0[i] + 1;
  104. ghh[i] = ghh[i] + 1;
  105. sfx[i] = sfx[i] + 1;
  106. sfy[i] = sfy[i] + 1;
  107. qIn[i] = qIn[i] + 1;
  108. for(int j = 0; j < nEdges; ++j) {
  109. flagInterface[i * nEdges + j] = !flagInterface[i * nEdges + j];
  110. typeInterface[i * nEdges + j] = typeInterface[i * nEdges + j] + 1;
  111. neighborIds[i * nEdges + j] = neighborIds[i * nEdges + j] + 1;
  112. }
  113. }
  114. }
  115. }
Success #stdin #stdout 1.74s 320256KB
stdin
Standard input is empty
stdout
0
100
200
300
Time: 1631