题解 P9384【[THUPC 2023 决赛] 着色】
有趣的构造题!
不存在三元环或五元环颜色相同看起来很诈骗,不妨加强一下问题,使得不存在奇环颜色相同。也就是说,每种颜色构成一个二分图。
又发现颜色数
具体地,我们使得连接
于是不存在奇环颜色相同,自然就不存在三元环或五元环颜色相同了。
//By: OIer rui_er
#include <bits/stdc++.h>
#define rep(x,y,z) for(int x=(y);x<=(z);x++)
#define per(x,y,z) for(int x=(y);x>=(z);x--)
#define debug(format...) fprintf(stderr, format)
#define fileIO(s) do{freopen(s".in","r",stdin);freopen(s".out","w",stdout);}while(false)
using namespace std;
typedef long long ll;
mt19937 rnd(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now().time_since_epoch()).count());
int randint(int L, int R) {
uniform_int_distribution<int> dist(L, R);
return dist(rnd);
}
template<typename T> void chkmin(T& x, T y) {if(x > y) x = y;}
template<typename T> void chkmax(T& x, T y) {if(x < y) x = y;}
int main() {
int n;
scanf("%d", &n);
rep(i, 1, n-1) {
rep(j, i+1, n) printf("%d", (int)__builtin_ctz(i ^ j));
puts("");
}
return 0;
}