Answer the question
In order to leave comments, you need to log in
How to use tags in PUG mixin when it is declared?
Hello!
Please help if you can.
There is a repeating part in the layout of the project. The layout is rendered in pug and I want to use the mixin.
Everything works, but there is a detail - part of the text needs hyphenation - tags <br>
.
How to insert them when declaring a mixin?
For example, a simple mixin:
mixin goods-block(title)
.goods-block
h4= title
+goods-block("Первая часть заголовка" + "<br>" + "Вторая часть")
<br>
as text.Answer the question
In order to leave comments, you need to log in
What you did not understand in the solution: you optimize the "black" half of the graph, forgetting that the smallest edge can be in the "white" one.
FOR EACH VERTEX: pointer to “chief” + inversion flag. If the vertex does not have a head, then it points to null.
A DIRECTOR is a vertex that has no bosses. We also assume that the director's inversion flag is always false.
Let's get the getInfoNonDestructive function, it returns a structure of two elements. First, it's the director (never null!!). Secondly, this is the color - XOR of the inversion flags from the top itself to the director.
The getInfo function will call getInfoNonDestructive and then OPTIMIZE THE STRUCTURE: IF the node has a leader THEN: node's head := director, node's inversion flag := node's color.
The merger of companies happens like this. The director of the firm becomes subordinate to one of the members of another firm.
INITIALLY for all vertices, the head is null, the inversion flag is false. That is, each vertex is white and its own director.
SOLUTION: Sort the edges in ascending order.
For each edge…
• Find information about the vertices — the ends of the edge.
• If the director is the same and the colors are different, we do nothing.
• If there is only one director and one color, output the weight of this edge as an answer.
• If the directors are different, we merge the firms. Twisting the inversion flag of the director that has disappeared, so that the colors of the vertices - ends of the edge are different. Even so.
VertexInfo info1 = getInfo(vertex1);
VertexInfo info2 = getInfo(vertex2);
if (…) {
info1.director->superior = info2.director;
VertexInfo info1new = getInfoNonDestructive(vertex1);
if (info1new.color == info2.color)
info1.director->inverseFlag = !info1.director->inverseFlag;
}
I thought that the graph can always be divided into two sets so that the vertices connected by the maximum edge are in one set, and the remaining vertices in the other, that is, the answer will always be the maximum edge. I tested my solution in yandex.contest and got an error on the 8th test. Please tell me what I misunderstood from the condition?
Maybe there is a counterexample?
4 4
0 1 2
1 2 1
2 3 0
3 0 1
You made a mistake here: the maximum edge could be a bridge, and having bitten it, you would break the graph into at least two subgraphs, plus a pair of pershin incident to the edge will be the third subgraph - and this is overkill.
Therefore, just sort through the edges in descending order, which one does not turn out to be a bridge - that will be the solution.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question