工 作(work.pas) pascal【问题描述】当前有n(n
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/16 03:37:06
工 作(work.pas) pascal【问题描述】当前有n(n
工 作(work.pas) pascal
【问题描述】
当前有n(n
工 作(work.pas) pascal【问题描述】当前有n(n
var
tot,toth,n:longint;
ok:boolean;
f:array [1..13,0..8] of longint;
a:array [1..13,1..2] of longint;
v:array [1..8,1..1000] of boolean;
procedure init;
var
i,j,k,x:longint;
begin
fillchar(f,sizeof(f),0);
fillchar(v,sizeof(v),true);
readln(n);
for i:=1 to n do
begin
read(a[i,1],a[i,2],k);
for j:=1 to k do
begin
inc(f[i,0]);
read(f[i,f[i,0]]);
end;
readln;
end;
ok:=false;
end;
function free(t,x,y:longint):boolean;
var
i,j:longint;
begin
for i:=x to y do
if v[t,i]=false then exit(false);
exit(true);
end;
procedure dfs(dep:longint);
var
i,j:longint;
begin
for i:=1 to f[dep,0] do
if free(f[dep,i],a[dep,1],a[dep,2]) then
begin
for j:=a[dep,1] to a[dep,2] do
v[f[dep,i],j]:=false;
if dep=n then begin writeln('YES'); ok:=true; exit; end
else dfs(dep+1);
if ok then exit;
for j:=a[dep,1] to a[dep,2] do
v[f[dep,i],j]:=true;
end;
end;
begin
readln(tot);
for toth:=1 to tot do
begin
init;
dfs(1);
if ok=false then writeln('NO');
end;
end.