这题我是用搜索做的
在搜的时候,如果check成立,那么就填色,不然就不填这个颜色
var n,k,m,i,tj,u,w:longint; a:array[0..1000,0..1000]of boolean; v:array[0..1000]of longint; function check(y,d:longint):longint; var i:longint; begin check:=0; for i:=1 to d-1 do if (a[d,i]=true)and(v[i]=y) then exit(1); end; procedure search(dep:longint); var i:longint; begin if dep>n then begin inc(tj); exit; end; for i:=1 to m do begin if check(i,dep)=0 then begin v[dep]:=i; search(dep+1); end; end; end; begin readln(n,k,m); for i:=1 to k do begin readln(u,w); a[u,w]:=true; a[w,u]:=true; end; tj:=0; search(1); write(tj); end.