牛客多校10 War of Inazuma (Easy Version) 构造

😊 | Powered By HeartFireY

Problem Description

题目大意:给定一个牛客多校10 War of Inazuma (Easy Version) 构造_ios​​维立方体,共有牛客多校10 War of Inazuma (Easy Version) 构造_ios_02​​​个节点。如果在立方体上两个节点相连,那么要求两个点的二进制表示有且仅有一位不同。现在要求你构造一个牛客多校10 War of Inazuma (Easy Version) 构造_ios_02​长度的牛客多校10 War of Inazuma (Easy Version) 构造_#define_04​​序列,表示每个点的颜色。要求每个点相邻的点中和这个点颜色相同的点的数目不超过牛客多校10 War of Inazuma (Easy Version) 构造_算法_05​​个。

首先分析每个点相邻点的情况:

牛客多校10 War of Inazuma (Easy Version) 构造_ios_06

我们可以得出规律,要是得构造的立方体定点分配满足题意,需要使得每个被染为牛客多校10 War of Inazuma (Easy Version) 构造_#define_07​和牛客多校10 War of Inazuma (Easy Version) 构造_#define_07​之间没有边,每个被染为牛客多校10 War of Inazuma (Easy Version) 构造_acm竞赛_09​和牛客多校10 War of Inazuma (Easy Version) 构造_acm竞赛_09​​之间没有边。对应到二进制的表示中去找规律:二进制表示中偶数个牛客多校10 War of Inazuma (Easy Version) 构造_acm竞赛_09的填牛客多校10 War of Inazuma (Easy Version) 构造_#define_07,奇数个牛客多校10 War of Inazuma (Easy Version) 构造_acm竞赛_09牛客多校10 War of Inazuma (Easy Version) 构造_acm竞赛_09或者反过来亦可。

按照这个规律,不停的翻转牛客多校10 War of Inazuma (Easy Version) 构造_#define_07牛客多校10 War of Inazuma (Easy Version) 构造_acm竞赛_09构造即可。

#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 50000010;
char s[N];

signed main(){
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int n = 0; cin >> n;
s[0] = '0';
for(int i = 1; i <= n; i++){
int len = strlen(s);
for(int i = 0; i < len; i++)
s[len + i] = '1' - s[i] + '0';
}
cout << s << endl;
return 0;
}