const finp='hcnln.inp'; fout='hcnln.out'; MAXN=105; type hcn=record x1,y1,x2,y2,vt: longint; end; var h: array[0..MAXN] of hcn; f,t: array[0..MAXN] of longint; i,j,n,kq: longint; procedure nhap; begin readln(n); for i:=1 to n do begin readln(h[i].x1,h[i].y1,h[i].x2,h[i].y2); h[i].vt:=i; end; end; function dientich(a:hcn):longint; begin exit((a.x2-a.x1)*(a.y2-a.y1)); end; function bao(a,b:hcn):boolean; // kt a bao b begin if (a.x1<=b.x1) and (b.x2<=a.x2) and (a.y1<=b.y1) and (b.y2<=a.y2) then exit(true) else exit(false); end; procedure sort; var i,j:longint; tam:hcn; begin for i:=1 to n-1 do for j:=1 to n-i do if (dientich(h[j]) < dientich(h[j+1])) then begin tam:=h[j];h[j]:=h[j+1];h[j+1]:=tam; end; end; procedure truyvet; var i:longint; begin i:=kq; repeat writeln(h[i].vt); i:=t[i]; until i=0; end; procedure xuli; var i,j,jmax:longint; begin sort; //for i:=1 to n do writeln(h[i].vt); f[0]:=0;f[1]:=1; //kq:=1; for i:=2 to n do begin jmax:=0; for j:=1 to i - 1 do if bao(h[j],h[i]) and (f[j]>f[jmax]) then jmax:=j; f[i]:=f[jmax]+1; t[i]:=jmax; end; kq:=0; for i:=1 to n do if f[i]>f[kq] then kq:=i; writeln(f[kq]); truyvet; end; begin assign(input,finp); reset(input); assign(output,fout); rewrite(output); nhap; xuli; close(input); close(output); end.
* Chuyên dạy lập trình ONLINE cho học sinh THCS, THPT *.
Mọi giao lưu, trao đổi, xin liên hệ: Lê Quang Vinh - zalo: 037.803.8755.
Page: Lớp học Code Sky
Group FB1: Ôn thi HSG9 - THTB - TS10 chuyên tin
Group FB2: Học Scratch - Ôn thi Tin học trẻ bảng A
Thứ Tư, 27 tháng 4, 2022
HCNLN PASCAL
Đăng ký:
Đăng Nhận xét (Atom)
Không có nhận xét nào:
Đăng nhận xét
Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.