#P9384. [THUPC 2023 决赛] 着色

    ID: 10546 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度普及+/提高− 上传者: 标签>2023Special JudgeO2优化构造THUPC

[THUPC 2023 决赛] 着色

Background

Ancient handwriting, ancient music, ancient history, the ancient K1000K_{1000}—if no one cares, it will quietly fade away.

Problem Description

You are given an undirected complete graph with nn nodes. You need to label each edge with a digit from 090 \sim 9, such that there does not exist any 3-cycle or 5-cycle in the graph where all edges on the cycle have the same digit.

Input Format

The input contains only one line with an integer nn, representing the number of nodes in the graph.

Output Format

If no solution exists, output one line with an integer -1. Otherwise, output (n1)(n-1) lines. On line ii, output (ni)(n-i) characters. The jj-th character on line ii represents the label of edge (i,i+j)(i,i+j). If there are multiple solutions, output any one.

4
012
34
5

Hint

Constraints

For all testdata, 2n10002 \le n \le 1000.

Source

From the final round of the 2023 Tsinghua University Student Algorithm and Programming Contest and Collegiate Invitational (THUPC2023).

Resources such as the editorial can be found at https://github.com/THUSAAC/THUPC2023.

Translated by ChatGPT 5