niyaznigmatullin

Decompiled Hopcroft-Karp

Jan 8th, 2017
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 11.74 KB | None | 0 0
  1. // InputReader.java
  2. import java.io.BufferedReader;
  3. import java.io.InputStream;
  4. import java.io.InputStreamReader;
  5. import java.io.Reader;
  6. import kotlin.Metadata;
  7. import kotlin.jvm.internal.IntCompanionObject;
  8. import kotlin.jvm.internal.Intrinsics;
  9. import org.jetbrains.annotations.NotNull;
  10.  
  11. @Metadata(
  12.    mv = {1, 1, 1},
  13.    bv = {1, 0, 0},
  14.    k = 1,
  15.    d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0000\u0018\u00002\u00020\u0001B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\u0006\u0010\u0005\u001a\u00020\u0006¨\u0006\u0007"},
  16.    d2 = {"LInputReader;", "Ljava/io/BufferedReader;", "inputStream", "Ljava/io/InputStream;", "(Ljava/io/InputStream;)V", "nextInt", "", "production sources for module kotlin"}
  17. )
  18. public final class InputReader extends BufferedReader {
  19.    public final int nextInt() {
  20.       int c;
  21.       for(c = this.read(); c >= 0 && c <= 32; c = this.read()) {
  22.          ;
  23.       }
  24.  
  25.       if(c < 0) {
  26.          return IntCompanionObject.MIN_VALUE;
  27.       } else {
  28.          boolean neg = (char)c == 45;
  29.          if(neg) {
  30.             c = this.read();
  31.          }
  32.  
  33.          int x;
  34.          for(x = 0; c > 32; c = this.read()) {
  35.             x = x * 10 + c - 48;
  36.          }
  37.  
  38.          return x;
  39.       }
  40.    }
  41.  
  42.    public InputReader(@NotNull InputStream inputStream) {
  43.       Intrinsics.checkParameterIsNotNull(inputStream, "inputStream");
  44.       super((Reader)(new InputStreamReader(inputStream)));
  45.    }
  46. }
  47. // AKt.java
  48. import java.io.InputStream;
  49. import kotlin.Metadata;
  50. import kotlin.jvm.internal.IntCompanionObject;
  51. import kotlin.jvm.internal.Intrinsics;
  52. import org.jetbrains.annotations.NotNull;
  53.  
  54. @Metadata(
  55.    mv = {1, 1, 1},
  56.    bv = {1, 0, 0},
  57.    k = 2,
  58.    d1 = {"\u0000\u001c\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u0011\n\u0002\u0010\u000e\n\u0002\b\u0002\u001a\u0019\u0010\u0004\u001a\u00020\u00052\f\u0010\u0006\u001a\b\u0012\u0004\u0012\u00020\b0\u0007¢\u0006\u0002\u0010\t\"\u0011\u0010\u0000\u001a\u00020\u0001¢\u0006\b\n\u0000\u001a\u0004\b\u0002\u0010\u0003¨\u0006\n"},
  59.    d2 = {"input", "LInputReader;", "getInput", "()LInputReader;", "main", "", "args", "", "", "([Ljava/lang/String;)V", "production sources for module kotlin"}
  60. )
  61. public final class AKt {
  62.    @NotNull
  63.    private static final InputReader input;
  64.  
  65.    public static final void main(@NotNull String[] args) {
  66.       Intrinsics.checkParameterIsNotNull(args, "args");
  67.  
  68.       while(true) {
  69.          int n1 = input.nextInt();
  70.          if(n1 == IntCompanionObject.MIN_VALUE) {
  71.             return;
  72.          }
  73.  
  74.          int n2 = input.nextInt();
  75.          int m = input.nextInt();
  76.          int[] from = new int[m];
  77.          int[] to = new int[m];
  78.          int g = 0;
  79.          int ans = from.length - 1;
  80.          if(g <= ans) {
  81.             while(true) {
  82.                to[g] = input.nextInt() - 1;
  83.                from[g] = input.nextInt() - 1;
  84.                if(g == ans) {
  85.                   break;
  86.                }
  87.  
  88.                ++g;
  89.             }
  90.          }
  91.  
  92.          Matching var11 = new Matching(n2, n1, from, to);
  93.          int[] var12 = var11.getMatching();
  94.          int i = var12.length;
  95.          System.out.println(i);
  96.  
  97.          for(int var9 = 0; var9 < var12.length; ++var9) {
  98.             i = var12[var9];
  99.             String var10 = i + 1 + " ";
  100.             System.out.print(var10);
  101.          }
  102.  
  103.          System.out.println();
  104.       }
  105.    }
  106.  
  107.    @NotNull
  108.    public static final InputReader getInput() {
  109.       return input;
  110.    }
  111.  
  112.    static {
  113.       InputStream var10002 = System.in;
  114.       Intrinsics.checkExpressionValueIsNotNull(System.in, "System.`in`");
  115.       input = new InputReader(var10002);
  116.    }
  117. }
  118. // Matching.java
  119. import java.util.Arrays;
  120. import kotlin.Metadata;
  121. import kotlin.collections.ArraysKt;
  122. import kotlin.jvm.internal.IntCompanionObject;
  123. import kotlin.jvm.internal.Intrinsics;
  124. import org.jetbrains.annotations.NotNull;
  125.  
  126. @Metadata(
  127.    mv = {1, 1, 1},
  128.    bv = {1, 0, 0},
  129.    k = 1,
  130.    d1 = {"\u0000\"\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\u0015\n\u0002\b\u0016\n\u0002\u0010\u000b\n\u0002\b\u0004\u0018\u00002\u00020\u0001B%\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0003\u0012\u0006\u0010\u0005\u001a\u00020\u0006\u0012\u0006\u0010\u0007\u001a\u00020\u0006¢\u0006\u0002\u0010\bJ\u0006\u0010\u001c\u001a\u00020\u001dJ\u000e\u0010\u001e\u001a\u00020\u001d2\u0006\u0010\u001f\u001a\u00020\u0003J\u0006\u0010 \u001a\u00020\u0006R\u0011\u0010\t\u001a\u00020\u0006¢\u0006\b\n\u0000\u001a\u0004\b\n\u0010\u000bR\u0011\u0010\f\u001a\u00020\u0006¢\u0006\b\n\u0000\u001a\u0004\b\r\u0010\u000bR\u0011\u0010\u0005\u001a\u00020\u0006¢\u0006\b\n\u0000\u001a\u0004\b\u000e\u0010\u000bR\u0011\u0010\u000f\u001a\u00020\u0006¢\u0006\b\n\u0000\u001a\u0004\b\u0010\u0010\u000bR\u0011\u0010\u0002\u001a\u00020\u0003¢\u0006\b\n\u0000\u001a\u0004\b\u0011\u0010\u0012R\u0011\u0010\u0013\u001a\u00020\u0006¢\u0006\b\n\u0000\u001a\u0004\b\u0014\u0010\u000bR\u0011\u0010\u0015\u001a\u00020\u0006¢\u0006\b\n\u0000\u001a\u0004\b\u0016\u0010\u000bR\u0011\u0010\u0017\u001a\u00020\u0006¢\u0006\b\n\u0000\u001a\u0004\b\u0018\u0010\u000bR\u0011\u0010\u0019\u001a\u00020\u0006¢\u0006\b\n\u0000\u001a\u0004\b\u001a\u0010\u000bR\u0011\u0010\u0007\u001a\u00020\u0006¢\u0006\b\n\u0000\u001a\u0004\b\u001b\u0010\u000b¨\u0006!"},
  131.    d2 = {"LMatching;", "", "n1", "", "n2", "from", "", "to", "(II[I[I)V", "cur", "getCur", "()[I", "d", "getD", "getFrom", "he", "getHe", "getN1", "()I", "next", "getNext", "p1", "getP1", "p2", "getP2", "q", "getQ", "getTo", "bfs", "", "dfs", "v", "getMatching", "production sources for module kotlin"}
  132. )
  133. public final class Matching {
  134.    @NotNull
  135.    private final int[] he;
  136.    @NotNull
  137.    private final int[] next;
  138.    @NotNull
  139.    private final int[] cur;
  140.    @NotNull
  141.    private final int[] p1;
  142.    @NotNull
  143.    private final int[] p2;
  144.    @NotNull
  145.    private final int[] q;
  146.    @NotNull
  147.    private final int[] d;
  148.    private final int n1;
  149.    @NotNull
  150.    private final int[] from;
  151.    @NotNull
  152.    private final int[] to;
  153.  
  154.    @NotNull
  155.    public final int[] getHe() {
  156.       return this.he;
  157.    }
  158.  
  159.    @NotNull
  160.    public final int[] getNext() {
  161.       return this.next;
  162.    }
  163.  
  164.    @NotNull
  165.    public final int[] getCur() {
  166.       return this.cur;
  167.    }
  168.  
  169.    @NotNull
  170.    public final int[] getP1() {
  171.       return this.p1;
  172.    }
  173.  
  174.    @NotNull
  175.    public final int[] getP2() {
  176.       return this.p2;
  177.    }
  178.  
  179.    @NotNull
  180.    public final int[] getQ() {
  181.       return this.q;
  182.    }
  183.  
  184.    @NotNull
  185.    public final int[] getD() {
  186.       return this.d;
  187.    }
  188.  
  189.    public final boolean bfs() {
  190.       int head = 0;
  191.       int tail = 0;
  192.       ArraysKt.fill$default(this.d, IntCompanionObject.MAX_VALUE, 0, 0, 6, (Object)null);
  193.       int v = 0;
  194.       int e = this.p1.length - 1;
  195.       if(v <= e) {
  196.          while(true) {
  197.             if(this.p1[v] < 0) {
  198.                this.q[tail++] = v;
  199.                this.d[v] = 0;
  200.             }
  201.  
  202.             if(v == e) {
  203.                break;
  204.             }
  205.  
  206.             ++v;
  207.          }
  208.       }
  209.  
  210.       while(head < tail) {
  211.          v = this.q[head++];
  212.  
  213.          for(e = this.he[v]; e >= 0; e = this.next[e]) {
  214.             int u = this.p2[this.to[e]];
  215.             if(u < 0) {
  216.                return true;
  217.             }
  218.  
  219.             if(this.d[u] == IntCompanionObject.MAX_VALUE) {
  220.                this.q[tail++] = u;
  221.                this.d[u] = this.d[v] + 1;
  222.             }
  223.          }
  224.       }
  225.  
  226.       return false;
  227.    }
  228.  
  229.    public final boolean dfs(int v) {
  230.       while(this.cur[v] >= 0) {
  231.          int e = this.cur[v];
  232.          int u = this.to[e];
  233.          int w = this.p2[u];
  234.          if(w < 0 || this.d[w] == this.d[v] + 1 && this.dfs(w)) {
  235.             this.p1[v] = u;
  236.             this.p2[u] = v;
  237.             return true;
  238.          }
  239.  
  240.          this.cur[v] = this.next[e];
  241.       }
  242.  
  243.       return false;
  244.    }
  245.  
  246.    @NotNull
  247.    public final int[] getMatching() {
  248.       int ans = 0;
  249.       int cn = this.from.length - 1;
  250.       if(ans <= cn) {
  251.          while(true) {
  252.             if(this.p1[this.from[ans]] < 0 && this.p2[this.to[ans]] < 0) {
  253.                this.p1[this.from[ans]] = this.to[ans];
  254.                this.p2[this.to[ans]] = this.from[ans];
  255.             }
  256.  
  257.             if(ans == cn) {
  258.                break;
  259.             }
  260.  
  261.             ++ans;
  262.          }
  263.       }
  264.  
  265.       while(true) {
  266.          do {
  267.             if(!this.bfs()) {
  268.                int[] var5 = new int[this.n1];
  269.                cn = 0;
  270.                int v = 0;
  271.                int var4 = this.d.length - 1;
  272.                if(v <= var4) {
  273.                   while(true) {
  274.                      if(this.d[v] != IntCompanionObject.MAX_VALUE) {
  275.                         var5[cn++] = v;
  276.                      }
  277.  
  278.                      if(v == var4) {
  279.                         break;
  280.                      }
  281.  
  282.                      ++v;
  283.                   }
  284.                }
  285.  
  286.                int[] var10000 = Arrays.copyOf(var5, cn);
  287.                Intrinsics.checkExpressionValueIsNotNull(var10000, "Arrays.copyOf(this, newSize)");
  288.                return var10000;
  289.             }
  290.  
  291.             ans = 0;
  292.             cn = this.cur.length - 1;
  293.             if(ans <= cn) {
  294.                while(true) {
  295.                   this.cur[ans] = this.he[ans];
  296.                   if(ans == cn) {
  297.                      break;
  298.                   }
  299.  
  300.                   ++ans;
  301.                }
  302.             }
  303.  
  304.             ans = 0;
  305.             cn = this.q.length - 1;
  306.          } while(ans > cn);
  307.  
  308.          while(this.d[this.q[ans]] == 0) {
  309.             this.dfs(this.q[ans]);
  310.             if(ans == cn) {
  311.                break;
  312.             }
  313.  
  314.             ++ans;
  315.          }
  316.       }
  317.    }
  318.  
  319.    public final int getN1() {
  320.       return this.n1;
  321.    }
  322.  
  323.    @NotNull
  324.    public final int[] getFrom() {
  325.       return this.from;
  326.    }
  327.  
  328.    @NotNull
  329.    public final int[] getTo() {
  330.       return this.to;
  331.    }
  332.  
  333.    public Matching(int n1, int n2, @NotNull int[] from, @NotNull int[] to) {
  334.       Intrinsics.checkParameterIsNotNull(from, "from");
  335.       Intrinsics.checkParameterIsNotNull(to, "to");
  336.       super();
  337.       this.n1 = n1;
  338.       this.from = from;
  339.       this.to = to;
  340.       int i = this.n1;
  341.       int[] i$iv = new int[i];
  342.       int i$iv1 = 0;
  343.       int it = i - 1;
  344.       byte var15;
  345.       if(i$iv1 <= it) {
  346.          while(true) {
  347.             var15 = -1;
  348.             i$iv[i$iv1] = var15;
  349.             if(i$iv1 == it) {
  350.                break;
  351.             }
  352.  
  353.             ++i$iv1;
  354.          }
  355.       }
  356.  
  357.       this.he = i$iv;
  358.       this.next = new int[this.from.length];
  359.       this.cur = new int[this.n1];
  360.       i = this.n1;
  361.       i$iv = new int[i];
  362.       i$iv1 = 0;
  363.       it = i - 1;
  364.       if(i$iv1 <= it) {
  365.          while(true) {
  366.             var15 = -1;
  367.             i$iv[i$iv1] = var15;
  368.             if(i$iv1 == it) {
  369.                break;
  370.             }
  371.  
  372.             ++i$iv1;
  373.          }
  374.       }
  375.  
  376.       this.p1 = i$iv;
  377.       int[] var16 = new int[n2];
  378.       int var17 = 0;
  379.       i$iv1 = n2 - 1;
  380.       if(var17 <= i$iv1) {
  381.          while(true) {
  382.             var15 = -1;
  383.             var16[var17] = var15;
  384.             if(var17 == i$iv1) {
  385.                break;
  386.             }
  387.  
  388.             ++var17;
  389.          }
  390.       }
  391.  
  392.       this.p2 = var16;
  393.       this.q = new int[this.n1];
  394.       this.d = new int[this.n1];
  395.       i = 0;
  396.       var17 = this.from.length - 1;
  397.       if(i <= var17) {
  398.          while(true) {
  399.             this.next[i] = this.he[this.from[i]];
  400.             this.he[this.from[i]] = i;
  401.             if(i == var17) {
  402.                break;
  403.             }
  404.  
  405.             ++i;
  406.          }
  407.       }
  408.  
  409.    }
  410. }
Advertisement
Add Comment
Please, Sign In to add comment