【BZOJ 3033】太鼓达人

相关链接

题目传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3033
神犇题解:http://blog.csdn.net/clover_hxy/article/details/56003661

解题报告

这个东西,看一看样例,感觉答案是$2^k$,然后写一发无脑贪心就过了

不过这题的证明非常妙妙啊:

考虑将每一个$0 \sim 2^{k+1}-1$的数看成一个点,标号为这个数
把在这个数末尾或者开头加$0/1$看作边
那么每个点度数恰好为$4$,并且整个图显然连通
那么这图显然存在欧拉回路,那么就能够一笔画

于是在这个图上贪心走就可以了

Code

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

const int N = 3000;

int n,k,arr[N];
set<int> S;

inline int read() {
	char c=getchar(); int f=1,ret=0;
	while (c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}
	while (c<='9'&&c>='0') {ret=ret*10+c-'0';c=getchar();}
	return ret * f;
}

inline int get(int p) {
	int ret = 0;
	for (int i=0;i<k;i++) ret += (1 << i) * arr[p + i];
	return ret; 
}

int main() {
	k = read(); n = 1 << k;
	for (int i=1;i<=k;i++) arr[i] = 0; S.insert(0);
	for (int i=n;i>n-k;i--) arr[i] = 1, S.insert(get(i));
	for (int i=2;i<=n-k;i++) {
		if (S.count(get(i))) arr[i+k-1] = 1;
		S.insert(get(i));
	}
	printf("%d ",n);
	for (int i=1;i<=n;i++) printf("%d",arr[i]);
	return 0;
}

15 thoughts to “【BZOJ 3033】太鼓达人”

  1. 139515 124229This sort of considering develop change in an individuals llife, building our Chicago Pounds reduction going on a diet model are a wide actions toward generating the fact goal in mind. lose weight 522911

  2. 486640 585786Wow, incredible weblog structure! How long have you been running a blog for? you created running a weblog look easy. The complete appear of your site is magnificent, neatly as the content material! 124375

  3. 386862 893670Aw, it was a very great post. In concept I would like to devote writing such as this furthermore,?C spending time and specific work to produce a terrific article?- nonetheless so what can I say?- I waste time alot and never at all seem to obtain 1 thing completed. 552343

  4. 455743 158817Oh my goodness! an outstanding post dude. Thank you Nevertheless Im experiencing dilemma with ur rss . Do not know why Cannot register for it. Could there be any person finding identical rss difficulty? Anybody who knows kindly respond. Thnkx 445992

  5. 416540 114366I was reading some of your content material on this site and I feel this internet website is genuinely informative! Keep putting up. 125812

  6. 696411 613923There is numerous separate years Los angeles Weight reduction eating plan with each a person is a necessity. The pioneer part can be your original obtaining rid of belonging to the extra pounds. la weight loss 713740

  7. 703796 730397Good one, there is in fact some excellent facts on this post some of my subscribers might uncover this helpful, will send them a link, a lot of thanks. 66036

  8. I keep listening to the newscast speak about receiving free online grant applications so I have been looking around for the top site to get one. Could you advise me please, where could i acquire some?

Leave a Reply

Your email address will not be published. Required fields are marked *