bzoj3632

时间:2025-04-05 10:08:09

裸的最大团,随机化大法好

多次随机出一个选择顺序然后贪心即可

 var b:array[..,..] of boolean;
a:array[..] of longint;
v:array[..] of boolean;
n,m,i,j,x,y,ans:longint; procedure swap(var a,b:longint);
var c:longint;
begin
c:=a;
a:=b;
b:=c;
end; procedure work;
var i,j,s:longint;
begin
s:=;
fillchar(v,sizeof(v),false);
for i:= to n do
if not v[a[i]] then
begin
v[a[i]]:=true;
for j:=i+ to n do
if not b[a[i],a[j]] then v[a[j]]:=true;
inc(s);
end;
if ans<s then ans:=s;
end; begin
readln(n);
while not eof do
begin
readln(x,y);
b[x,y]:=true;
b[y,x]:=true;
end;
for i:= to n do
a[i]:=i;
work;
for i:= to do
begin
for j:= to n do
swap(a[j],a[trunc(random*j)+]);
work;
end;
writeln(ans);
end.