牛客多校10 War of Inazuma (Easy Version) 构造
😊 | Powered By HeartFireY |
Problem Description
题目大意:给定一个维立方体,共有个节点。如果在立方体上两个节点相连,那么要求两个点的二进制表示有且仅有一位不同。现在要求你构造一个长度的序列,表示每个点的颜色。要求每个点相邻的点中和这个点颜色相同的点的数目不超过个。
首先分析每个点相邻点的情况:
我们可以得出规律,要是得构造的立方体定点分配满足题意,需要使得每个被染为和之间没有边,每个被染为和之间没有边。对应到二进制的表示中去找规律:二进制表示中偶数个的填,奇数个填或者反过来亦可。
按照这个规律,不停的翻转和构造即可。