1. Trang chủ
  2. » Giáo Dục - Đào Tạo

Đề thi Đề kiểm tra Tin DAn vong 1

4 70 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 4
Dung lượng 47 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Trang 1

Trang 1

SỞ GIÁO DỤC & ĐÀO TẠO KỲ THI CHỌN ĐỘI TUYỂN HỌC SINH GIỎI TỈNH

NĂM HỌC 2011-2012

ĐẮK LẮK MÔN : TIN HỌC 12 - THPT

Ngày thi 29/11/2011

ĐÁP ÁN VÀ HƯỚNG DẪN CHẤM VÒNG 1

I Phần chương trình nguồn

BÀI 1

{$A+,B-,D+,E+,F-,G-,I+,L+,N-,O-,P-,Q-,R+,S+,T-,V+,X+}

{$M 16384,0,655360}

const max =250;

fi ='BAI1.INP';

fo ='BAI1.OUT';

var l :array[1 max+1,1 max+1]of byte;

a,b,c :string;

procedure docf;

var f :text;

begin

assign(f,fi);

reset(f);

readln(f,a);readln(f,b);

close(f);

end;

function maxso(x,y,z:byte):byte;

begin

if x<y then x:=y;

if x<z then maxso:=z else maxso:=x;

end;

procedure lam;

var i,j,k,x,y,m :integer;

ch :char;

begin

fillchar(l,sizeof(l),0);

for i:=length(a) downto 1 do

for j:=length(b) downto 1 do

l[i,j]:=maxso(l[i+1,j],l[i,j+1],l[i+1,j+1]+ord(a[i]=b[j]));

m:=0;c:='0';

for ch:='9'downto '1' do

begin

i:=pos(ch,a);j:=pos(ch,b);

if (i>0)and(j>0)and(l[i,j]>m) then begin c:=ch;m:=l[i,j];end;

end;

i:=pos(c,a)+1;j:=pos(c,b)+1;

for k:=m-1 downto 1 do

for ch:='9'downto '0' do

begin

x:=i;y:=j;

Trang 2

Trang 2 while (x<=length(a))and(a[x]<>ch) do inc(x);

while (y<=length(b))and(b[y]<>ch) do inc(y);

if l[x,y]=k then

begin

c:=c+ch;i:=x+1;j:=y+1;

break;

end;

end;

end;

procedure ghif;

var f :text;

begin

assign(f,fo);

rewrite(f);

write(f,c);

close(f);

end;

BEGIN

docf;

lam;

ghif;

END

BÀI 2

Program Chia_luoi ;

Uses Crt ;

Const Fi = 'BAI2.INP';

Fo = 'BAI2.OUT';

Var A : Array[1 20,1 20]Of Integer ;

B : Array[1 20,1 20]Of 0 1 ;

Px,Py: Array[1 4] Of ShortInt ;

M,N,S,S1,S2 : LongInt ;

F : Text ;

Procedure Read_Input ;

Var i,j :Integer;

Begin

Clrscr ; S:= 0 ;

Assign(F,Fi) ;Reset(F) ;

Readln(F,M,N);

For i:=1 to M do

Begin

For j:=1 to N do

Begin

Read(F,A[i,j]);

S:=S+A[i,j];

End;

Readln(F);

End;

Close(F);

End;

Trang 3

Trang 3 Procedure Innit ;

Begin

S1 := S div 2;

Px[1]:= 0 ;Px[2]:= 0 ;Px[3]:=1 ;Px[4]:=-1 ;

Py[1]:= 1 ;Py[2]:=-1 ;Py[3]:=0 ;Py[4]:= 0 ;

End ;

Procedure Write_Output ;

Var i,j :Integer;

Begin

Assign(F,Fo); ReWrite(F);

For i:=1 to M do

Begin

For j:=1 to N do

Write(F,B[i,j],' ');

Writeln(F);

End;

Close(F);Halt;

End;

Function Ktra(x,y : Integer) : Boolean ;

Begin

Ktra:= False ;

If (x in [1 M]) And (y in [1 N]) And

(B[x,y] = 0 ) Then Ktra := True ;

End;

Procedure Try(x,y:Integer ;Sum :LongInt);

Var i :Integer ;

Begin

For i:=1 to 4 do

If Ktra(x+Px[i],y+Py[i]) Then

Begin

x := x + Px[i] ;

y := y + Py[i] ;

Sum := Sum + A[x,y];

B[x,y] := 1;

If Sum = S2 Then Write_Output ;

Try(x,y,Sum) ;

Sum := Sum - A[x,y];

B[x,y] := 0;

x := x - Px[i] ;

y := y - Py[i] ;

End ;

End;

Procedure Run ;

Var i,j : Integer ;

Begin

Read_Input ;Innit ;

For i:=1 to M do

For j:=1 to N do

If A[i,j]>= S1 Then

Begin

Trang 4

Trang 4 Fillchar(B,SizeOf(B),0);

B[i,j]:=1;

Write_Output;

End ;

For S2 := S1 downto 1 do

Begin

Fillchar(B,SizeOf(B),0);

B[1,1]:=1;

Try(1,1,A[1,1]);

End;

End;

BEGIN

Run;

END

II Test chấm

Bài 1: 5 Test, mỗi test đúng cho 2 điểm

Bài 2: 5 Test, mỗi test đúng cho 2 điểm

HD: Kết quả có thể có nhiều hơn một phương án do đó yêu cầu giám khảo xem xét kỹ khi chấm bài.

Hết

Ngày đăng: 28/08/2017, 23:48

TỪ KHÓA LIÊN QUAN

w