HDU ACM 1530 Maximum clique-> Largest group

Source: Internet
Author: User

Analysis: The largest group of template problems, Dfs deep search.

#include <iostream>using namespace std; #define N 55int map[n][n];int set[n];int max;bool isconnect (int end,int v) { int I;for (i=0;i<end;i++) if (!map[set[i]][v]) return False;return true; void DFS (int depth,int u,int n) {int i;if (depth+ (n-(u-1)) <=max)  //Pruning, no return at the back than the previous large; for (i=u;i<=n;i++) if (Isconnect (depth,i)) {Set[depth]=i;dfs (depth+1,i+1,n);    Recursive search sequential node}if (DEPTH>MAX)       //Update Max Max=depth;} int main () {int n,i,j;while (scanf ("%d", &n) ==1 && N) {for (i=1;i<=n;i++) for (j=1;j<=n;j++) scanf ("%d", &MAP[I][J]); Max=0;dfs (0,1,n);             Search printf from the first vertex of layer No. 0 ("%d\n", Max);} return 0;}


HDU ACM 1530 Maximum clique-> Largest group

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.