裸的最大团,随机化大法好
多次随机出一个选择顺序然后贪心即可
1 var b:array[0..51,0..51] of boolean; 2 a:array[0..51] of longint; 3 v:array[0..51] of boolean; 4 n,m,i,j,x,y,ans:longint; 5 6 procedure swap(var a,b:longint); 7 var c:longint; 8 begin 9 c:=a; 10 a:=b; 11 b:=c; 12 end; 13 14 procedure work; 15 var i,j,s:longint; 16 begin 17 s:=0; 18 fillchar(v,sizeof(v),false); 19 for i:=1 to n do 20 if not v[a[i]] then 21 begin 22 v[a[i]]:=true; 23 for j:=i+1 to n do 24 if not b[a[i],a[j]] then v[a[j]]:=true; 25 inc(s); 26 end; 27 if ans<s then ans:=s; 28 end; 29 30 begin 31 readln(n); 32 while not eof do 33 begin 34 readln(x,y); 35 b[x,y]:=true; 36 b[y,x]:=true; 37 end; 38 for i:=1 to n do 39 a[i]:=i; 40 work; 41 for i:=1 to 15000 do 42 begin 43 for j:=2 to n do 44 swap(a[j],a[trunc(random*j)+1]); 45 work; 46 end; 47 writeln(ans); 48 end.