"BZOJ-3033" too drum talent Eulerian graph + Mob Search

Source: Internet
Author: User

3033: Taiko time limit:1 Sec Memory limit:128 MB
submit:204 solved:154
[Submit] [Status] [Discuss] Description

On the Tanabata festival, Vani led CL's hand and happily walked through the bright lights and cheerful atmosphere. At this time, suddenly appeared in front of a too drum talent machine, and sitting at the machine is just being elite team members Xlk, Poet_shy and Lydrainbowcat rescued out of the Applepi. See two people to too drum up people have interest, Applepi decisive Flash, so CL picked up the drum stick ready to challenge. However, even in the ordinary difficulty, CL's pedestrian nature has been fully exposed. The end of a song, not only did not pass, even the drums are not spiritual. Vani very sorry, decided to help staff repair drums.

The main component of a drum is a sensor with a circle of M. Each sensor has two operating states, open and closed, denoted by 1 and 0 respectively. Obviously, a continuous check of k sensors in a clockwise direction from a different position can be achieved by 01 strings with a m length of K. Vani know that this m 01 string should be different from each other. And the drum design is very sophisticated, m will take the maximum possible value. Now that Vani has learned the value of K, he wants you to find the value of M, and give the sensor arrangement scheme with the smallest dictionary order.

Input

An integer k.

Output

An integer m and a binary string separated by a space. Represents the maximum possible m, and the minimum arrangement scheme for the dictionary order, the character 0 indicates off, and 1 indicates on. The first word and the last word of the string you output are adjacent.

Sample Input3
Sample Output8 00010111
HINT

The resulting 8 01 strings are 000, 001, 010, 101, 011, 111, 110, and 100 respectively. Note that the front and back are adjacent. There are only 8 binary strings with a length of 3, so M = 8 must be the maximum possible value.

For all test points, 2≤k≤11.

Source

Poetize2

Solution

For a while, I'm sure the first question is $2^{k}$ but it's not going to pass. The second question does not

In fact, before doing is dedicated to Oulatulai Qaq

Good BA, it is obviously a Eulerian graph, each stage has two points $0$ and $1$, it is obvious that each point in the Read = out = 2, then it is in line with the decision of Eulerian graph

So the correctness of the first question

Because it is Eulerian graph, there must be Euler's path, then only need to search the whole plot of the answer can be, because Eulerian graph, the time complexity of the search is actually $o (n) $, because almost can be considered to go to the end

So you can 1s without pressure over all points

revelation: something that seems to be not much related to the graph, should broaden the mind to try to rely on the figure, using some nature may find some good things (better chestnut: Ink equation)

Code
#include <iostream>#include<cstdio>#include<algorithm>#include<cmath>#include<cstring>using namespacestd;intm,k,ans[1<< A];BOOLvisit[1<< A];BOOLDFS (intXintDEP) {    if(Visit[x])return 0; VISIT[X]=1; ANS[DEP]=x>> (K-1); if(dep==m)return 1; if(DFS (x<<1) & (M-1), dep+1))return 1; if(DFS (x<<1|1) & (M-1), dep+1))return 1; VISIT[X]=0; return 0;}intMain () {scanf ("%d", &k); printf"%d", m=1<<K); DFS (0,1);  for(intI=1; i<=m; i++) printf ("%d", Ans[i]); return 0;} 

Suddenly want to do Eulerian graph reason lies in the English compulsory five Unit1 of a certain reading actually speak of Eulerian graph Tat, found himself did not seem to have done ah ...

"BZOJ-3033" too drum talent Eulerian graph + Mob Search

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.