[Dynamic Planning] Hacker attacks & #39; s CrackDown ultraviolet A 11825, crackdown11825

Source: Internet
Author: User

[Dynamic Planning] Hacker's CrackDown ultraviolet A 11825, crackdown11825


The abstract mathematical model is to take as many subsets as possible, so that each subset can cover the complete set.


# Include <algorithm> # include <cstring> # include <cstdio> using namespace std; int n; int P [1000], cover [1000], f [1000]; int main () {scanf ("% d", & n); for (int I = 0; I <n; I ++) {int m, x; scanf ("% d", & m); P [I] = 1 <I; while (m --) {scanf ("% d", & x ); P [I] | = (1 <x) ;}} for (int S = 1; S <n; S ++) {cover [S] = 0; for (int I = 0; I <n; I ++) {if (S & (1 <I) cover [S] | = P [I];} f [0] = 0; int ALL = (1 <n)-1; for (int S = 1; S <n; S ++) {f [S] = 0; for (int S0 = S; S0; S0 = (S0-1) & S) // This is the most important part, subset operation {if (cover [S0] = ALL) {f [S] = max (f [S], f [S ^ S0] + 1 ); // compare the complement set + 1 with the maximum value} printf ("% d", f [ALL]); return 0 ;}


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.