Codeforces 256 D liars and Serge

Source: Internet
Author: User

Click here to view the question

After reading the question for a long time, I understood the question for a long time. When I typed a combination, C [I] [J] was wrong .......

This may be the end of the test. Try not to drop too many homework in the first half of the next semester.

The key to this question is true/false, true/false --

There are n people. Some people tell the truth, some people say false things, and everyone knows whether all people say false things or tell the truth. Now ask each of them: the number of people who tell the truth. Everyone will give an answer. AI,

People who say false things will give a random number, but will not give a real answer. Now, I will give you two n k numbers and ask you how many N number solutions are there, we can determine that there are exactly K people lying.


Note the key point: if K has no K people, k people are lying.

Then we start to construct. Suppose there are n vacancies, and we will answer 1 2 3 in sequence .. N people put in these vacancies, set f [I] [J] [k] to 1 ~ J of I members have already been put into the vacant space, and K of them have already been determined to lie,

Next, let's talk about I + 1 people, with N-J vacancies left. Naturally, we need to enumerate the number of people who say I + 1 L, if l = I + 1, we are not sure whether these people are lying or not.

So the transfer is as follows:

If (L = I + 1) f [I + 1] [J + L] [k] = (F [I + 1] [J + L] [k] + F [I] [J] [K] * C [n-J] [l] % mod) % MOD;
Else f [I + 1] [J + L] [K + L] = (F [I + 1] [J + L] [K + L] + F [I] [J] [k] * C [n-J] [l] % mod) % MOD;

The complexity is the fourth power, but n is the exponential power of 2, so let's create a table.

Code

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.