Source: CMO-2014-P5
Category: Graph Theory

Problem: A meeting has $30$ participants. It is known that each person has at most $5$ acquaintances among the others, and in any group of $5$ people, there exist two who are not acquaintances. Find the largest positive integer $k$ such that, under the given conditions, there always exist $k$ people who are pairwise non-acquaintances.

Answer: $k=6$

Reference solution:
The largest positive integer $k$ is $6$.

We model the problem using a simple graph $G$. Let the $30$ participants be represented by $30$ vertices, and draw an edge between two vertices if the corresponding people are acquaintances. Let $V$ denote the vertex set of $G$. By the given conditions, every vertex in $G$ has degree at most $5$, and any set of $5$ vertices contains at least two vertices that are not adjacent. We are looking for the largest integer $k$ such that $G$ always contains an independent set of size at least $k$.

First, we prove that the size of a maximum independent set in $G$ is at least $6$.  
Let $X$ be a maximum independent set of $G$. By the maximality of $X$, every vertex in $V \setminus X$ must be adjacent to at least one vertex in $X$. (Otherwise, if some $a \in V \setminus X$ were not adjacent to any vertex in $X$, we could add $a$ to $X$ to obtain a strictly larger independent set, a contradiction.) Since each vertex in $X$ has degree at most $5$, the number of edges between $X$ and $V \setminus X$ is at most $5|X|$. Thus, we have
$$ 5|X| \ge |V \setminus X| = 30 - |X|, $$
which yields $6|X| \ge 30$, so $|X| \ge 5$.

If $|X| = 5$, then the inequality $5|X| \ge 30 - |X|$ becomes an equality. This implies that each vertex in $X$ is adjacent to exactly $5$ vertices in $V \setminus X$, and the neighbor sets of any two distinct vertices in $X$ are disjoint. Let $X = \{a, b, c, d, e\}$, and let the neighbor set of $a$ be
$$ Y_a = \{y_1, y_2, y_3, y_4, y_5\}. $$
By the problem condition, among the $5$ vertices in $Y_a$, there must be two that are not adjacent; without loss of generality, let them be $y_1$ and $y_2$. Since the neighbor sets of the vertices in $X$ are disjoint, neither $y_1$ nor $y_2$ is adjacent to any of $b, c, d, e$. Therefore,
$$ \{y_1, y_2, b, c, d, e\} $$
is an independent set in $G$ of size $6$, contradicting the assumption that the maximum independent set $X$ has size $5$. Hence, we must have $|X| \ge 6$.

Next, we prove that there exists a graph $G$ satisfying the conditions for which the maximum independent set has exactly $6$ vertices.  
Partition the vertex set $V$ into three subsets $V_1, V_2, V_3$ such that
$$ |V_1| = |V_2| = |V_3| = 10. $$
Let $V_1 = \{a_1, a_2, \dots, a_{10}\}$. We define the edges within $V_1$ by declaring that $a_i$ is adjacent to
$$ a_{i+1}, \; a_{i+4}, \; a_{i+5}, \; a_{i+6}, \; a_{i+9}, $$
where the indices are taken modulo $10$. We define the edges within $V_2$ and $V_3$ in exactly the same way. For $1 \le i < j \le 3$, there are no edges between $V_i$ and $V_j$.

We now verify that this graph $G$ meets all the required conditions:

1. Every vertex of $G$ has degree exactly $5$.

2. Any $5$ vertices in $G$ contain two vertices that are not adjacent. It suffices to check that there is no clique of size $5$. Any such clique would have to be contained entirely within one component, say $V_1$. If it contains $a_i$, the other $4$ vertices must be chosen from its neighbors $a_{i+1}, a_{i+4}, a_{i+5}, a_{i+6}, a_{i+9}$. However, $a_{i+1}$ is not adjacent to $a_{i+4}$, and $a_{i+6}$ is not adjacent to $a_{i+9}$. Thus, it is impossible to choose $4$ pairwise adjacent neighbors of $a_i$.

3. The maximum independent set in $G$ has size $6$. Suppose $a_{i_1}, a_{i_2}, a_{i_3}$ are three distinct vertices in $V_1$ such that $a_{i_1}$ is not adjacent to $a_{i_2}$, and $a_{i_2}$ is not adjacent to $a_{i_3}$. By the construction of $V_1$, non-adjacent vertices must have index differences of $2$ or $3$ modulo $10$. Thus,
$$ |i_1 - i_2| \equiv 2 \text{ or } 3 \pmod{10}, \qquad |i_2 - i_3| \equiv 2 \text{ or } 3 \pmod{10}. $$
It follows that the non-zero difference $|i_1 - i_3| \pmod{10}$ must be one of $\pm 1, \pm 4, \text{ or } 5$. Since all these differences correspond to adjacent vertices, $a_{i_1}$ and $a_{i_3}$ must be adjacent. This shows that the largest independent set in $V_1$ has size at most $2$. Consequently, the largest independent set in $G$ has size $2 \times 3 = 6$.

We conclude that the largest positive integer $k$ is $6$.

Grading guidelines:
(Partial) 1. Modeled the problem as a graph and identified the goal as finding a lower bound on the independence number (and/or an upper bound via a construction). 2. Proved the basic bound using a maximal independent set X and degree ≤5: every vertex outside X is adjacent to X, hence 5|X| ≥ 30−|X| and so |X| ≥ 5. 3. Used the “any 5 vertices contain two non-adjacent” condition to exclude some small-clique configuration (e.g. observed that the graph has no K5). 4. Gave a plausible extremal construction idea (e.g. disjoint union of 3 graphs on 10 vertices each with maximum independent set 2), but did not fully verify the required properties. (Almost) 1. Proved |X|≥6 via the maximal independent set counting argument and the equality case |X|=5 leading to disjoint neighbor sets, but left a small gap in deriving the disjointness/forcing the equality structure. 2. Completed the lower bound and presented a construction intended to show k≤6, but did not fully check one of: degree ≤5, absence of a 5-clique (the “any 5 contain two non-adjacent” condition), or that the maximum independent set in the construction is exactly 6. 3. Solution is almost complete, but made minor mistakes which are not negligible.

Construction task:
Construct an explicit 30x30 adjacency matrix representing the acquaintance graph that proves the boundary value $k$ is tight. 

Output requirements:
- The construction must be a single Python expression. Evaluating this expression must directly return the required 30x30 adjacency matrix.
- The value of the expression must be a single Python list of lists representing the 30x30 adjacency matrix.
- Use 0 and 1 for the matrix elements.
- The matrix must represent an undirected simple graph (it must be symmetric, with 0s on the main diagonal).
- The graph must satisfy the constraints: max degree $\le 5$, and no clique of size 5 ($K_5$).
- The maximum independent set size of the graph must be exactly the boundary value $k$ implied by the problem.
- Do not use explanations, comments, assignments, imports, function definitions, or any non-expression content.
- Put ONLY the Python expression inside the `<construct>` block.

Reference construction:
[[int(i != j and (((j // 6 - i // 6) % 5, (j % 6 - i % 6) % 6) in {(0, 3), (1, 0), (1, 3), (4, 0), (4, 3)})) for j in range(30)] for i in range(30)]

Verifier code:
import sys
import itertools

def solve():
    payload = sys.stdin.read().strip()
    if not payload:
        print("Empty input.")
        return
    try:
        matrix = eval(payload, {"__builtins__": {}, "range": range, "int": int}, {})
    except Exception as e:
        print(f"Failed to evaluate construction: {e}")
        return

    if not isinstance(matrix, list) or len(matrix) != 30:
        print("Matrix must be a list of 30 rows.")
        return
    for i, row in enumerate(matrix):
        if not isinstance(row, list) or len(row) != 30:
            print(f"Row {i} must be a list of 30 elements.")
            return
        for j, val in enumerate(row):
            if val not in (0, 1):
                print(f"Element at ({i}, {j}) is not 0 or 1.")
                return

    for i in range(30):
        if matrix[i][i] != 0:
            print(f"Diagonal element at ({i}, {i}) is not 0.")
            return
        for j in range(30):
            if matrix[i][j] != matrix[j][i]:
                print(f"Matrix is not symmetric at ({i}, {j}).")
                return

    for i in range(30):
        deg = sum(matrix[i])
        if deg > 5:
            print(f"Vertex {i} has degree {deg} > 5.")
            return

    for i in range(30):
        neighbors = [j for j in range(30) if matrix[i][j] == 1]
        if len(neighbors) >= 4:
            for combo in itertools.combinations(neighbors, 4):
                is_clique = True
                for u, v in itertools.combinations(combo, 2):
                    if matrix[u][v] == 0:
                        is_clique = False
                        break
                if is_clique:
                    print(f"Found a clique of size 5 including vertex {i}: {tuple([i] + list(combo))}")
                    return

    def get_max_independent_set_size(adj):
        n = len(adj)
        max_size = 0
        comp_neighbors = [0] * n
        for i in range(n):
            for j in range(n):
                if i != j and adj[i][j] == 0:
                    comp_neighbors[i] |= (1 << j)

        def bk(r, p, x):
            nonlocal max_size
            r_count = bin(r).count('1')
            p_count = bin(p).count('1')

            if p == 0 and x == 0:
                if r_count > max_size:
                    max_size = r_count
                return

            if r_count + p_count <= max_size:
                return

            pivot = -1
            max_p_intersect = -1
            union_px = p | x
            temp = union_px
            while temp > 0:
                lsb = temp & -temp
                i = lsb.bit_length() - 1
                intersect = p & comp_neighbors[i]
                c = bin(intersect).count('1')
                if c > max_p_intersect:
                    max_p_intersect = c
                    pivot = i
                temp &= temp - 1

            explore = p & ~comp_neighbors[pivot] if pivot != -1 else p
            while explore > 0:
                v = explore & -explore
                v_idx = v.bit_length() - 1
                bk(r | v, p & comp_neighbors[v_idx], x & comp_neighbors[v_idx])
                p &= ~v
                x |= v
                explore &= ~v

        bk(0, (1 << n) - 1, 0)
        return max_size

    mis_size = get_max_independent_set_size(matrix)
    if mis_size != 6:
        print(f"Maximum independent set size is {mis_size}, expected exactly 6.")
        return

    print("True")

if __name__ == "__main__":
    solve()