Advertisement
Guest User

Untitled

a guest
Apr 8th, 2020
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1.  private void validateEdges() {
  2.             int[] position = new int[k];
  3.             Arrays.fill(position, s);
  4.             for (int i = 0; i < days; i++) {
  5.                 ships.clear();
  6.                 for (int j = 0; j < k; j++) {
  7.                     for (Edge edge : g.get(position[j]).edges){
  8.                         if (edge.flow >= 1) {
  9.                             edge.flow -= 1;
  10.                             if (position[j] + n != edge.to) {
  11.                                 ships.add(new Pair(j, edge.to % n));
  12.                             }
  13.                             position[j] = edge.to;
  14.                             break;
  15.                         }
  16.                     }
  17.                 }
  18.  
  19.                 System.out.print(ships.size() + " ");
  20.                 for (Pair ship : ships) {
  21.                     System.out.print(ship.first + 1 + " " + (ship.second + 1) + " ");
  22.                 }
  23.                 System.out.println();
  24.             }
  25.  
  26.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement