Ejemplo n.º 1
0
  /** Get an initial set of action parameters associated with an upstream node. */
  public TreeMap<String, ActionParam> getInitialSourceParams() {
    TreeMap<String, ActionParam> params = new TreeMap<String, ActionParam>();

    {
      ActionParam param =
          new IntegerActionParam("Order", "Evaluates the MEL script in this order.", 100);
      params.put(param.getName(), param);
    }

    return params;
  }
Ejemplo n.º 2
0
  int Query() {
    int minimum = 100001;

    visited = new boolean[V];
    Arrays.fill(visited, false);

    depth = new int[V];
    Arrays.fill(depth, -1);

    low = new int[V];
    Arrays.fill(low, -1);

    parent = new int[V];
    Arrays.fill(parent, -1);

    articulationPoints = new TreeMap<Integer, Boolean>();

    getArticulationPoints(0, 0);

    for (Map.Entry<Integer, Boolean> entry : articulationPoints.entrySet()) {
      int i = (int) entry.getKey();
      if (RatingScore[i] < minimum) {
        minimum = RatingScore[i];
      }
    }

    return minimum != 100001 ? minimum : -1;
  }
Ejemplo n.º 3
0
  void run() throws Exception {
    // for this PS3, you can alter this method as you see fit

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    int TC = Integer.parseInt(br.readLine()); // there will be several test cases
    while (TC-- > 0) {
      br.readLine(); // ignore dummy blank line
      V = Integer.parseInt(br.readLine());

      StringTokenizer st = new StringTokenizer(br.readLine());
      // read rating scores, A (index 0), B (index 1), C (index 2), ..., until the V-th index
      RatingScore = new int[V];
      for (int i = 0; i < V; i++) {
        RatingScore[i] = Integer.parseInt(st.nextToken());
      }

      // clear the graph and read in a new graph as Adjacency Matrix
      AdjMatrix = new TreeMap<Integer, TreeMap<Integer, Boolean>>();
      for (int i = 0; i < V; i++) {
        st = new StringTokenizer(br.readLine());
        int k = Integer.parseInt(st.nextToken());

        TreeMap<Integer, Boolean> g = AdjMatrix.get(i);
        if (g == null) {
          g = new TreeMap<Integer, Boolean>();
          AdjMatrix.put(i, g);
        }

        while (k-- > 0) {
          int j = Integer.parseInt(st.nextToken());

          g.put(j, true);
          TreeMap<Integer, Boolean> gCon = AdjMatrix.get(j);
          if (gCon == null) {
            gCon = new TreeMap<Integer, Boolean>();
            AdjMatrix.put(j, gCon);
          }

          gCon.put(i, true);
        }
      }

      pr.println(Query());
    }
    pr.close();
  }
Ejemplo n.º 4
0
  /** Get an initial set of action parameters associated with an upstream node. */
  public TreeMap<String, ActionParam> getInitialSourceParams() {
    TreeMap<String, ActionParam> params = new TreeMap<String, ActionParam>();

    {
      ActionParam param =
          new IntegerActionParam("Order", "Loads the Houdini scene in this order.", 100);
      params.put(param.getName(), param);
    }

    {
      ActionParam param =
          new StringActionParam(
              "MergePattern",
              "Specifies the pattern used to select the components to be merged into the "
                  + "current scene.",
              "*");
      params.put(param.getName(), param);
    }

    return params;
  }
Ejemplo n.º 5
0
  void getArticulationPoints(int i, int d) {
    visited[i] = true;
    depth[i] = d;
    low[i] = d;
    int childCount = 0;
    boolean isArticulation = false;

    for (Map.Entry<Integer, Boolean> entry : AdjMatrix.get(i).entrySet()) {
      int ni = (int) entry.getKey();

      if (!visited[ni]) {
        parent[ni] = i;
        getArticulationPoints(ni, d + 1);
        childCount++;

        int low_i = low[i];
        int low_ni = low[ni];
        int depth_i = depth[i];

        if (low_ni != -1 && depth_i != -1 && (low_ni >= depth_i)) {
          isArticulation = true;
        }
        if (low_i != -1 && low_ni != -1) {
          low[i] = Math.min(low_i, low_ni);
        } else if (low_i == -1 && low_ni != -1) {
          low[i] = low_ni;
        } else if (low_i != -1 && low_ni == -1) {
          low[i] = low_i;
        }
      } else if (ni != parent[i]) {
        int depth_ni = depth[ni];
        int low_i = low[i];

        if (low_i != -1 && depth_ni != -1) {
          low[i] = Math.min(low_i, depth_ni);
        } else if (low_i == -1 && depth_ni != -1) {
          low[i] = depth_ni;
        } else if (low_i != -1 && depth_ni == -1) {
          low[i] = low_i;
        }
      }
    }

    int parent_i = parent[i];

    if ((parent_i != -1 && isArticulation) || (parent_i == -1 && childCount > 1)) {
      articulationPoints.put(i, true);
    }
  }