Главная » Статьи » Задачи с acm.timus.ru » Пакет решений на 15.03.08 |
1125
Var a:array[1..50,1..50] of boolean; b:array[1..50,1..50] of LOngint; v:array[1..500] of record x,y: LongInt; End; ch:Char; l:Real; R: Boolean; i,j,i1,j1,n,m,t,k:LongInt; Begin FillChar(b,SizeOf(b),0); FillChar(a,SizeOf(a),0); FillChar(v,SizeOf(v),0); K:=0; For I:=1 to 50 do For J:=1 to 50 do If Sqrt(i*i+j*j)=Int(Sqrt(i*i+j*j)) then begin Inc(K); V[K].x:=I; V[K].y:=J; End; Readln(n,m); For i:=1 to n do begin For j:=1 to m do begin Read(ch); If ch='W' then A[i,j]:=True else A[i,j]:=False; End; Readln; End; For i:=1 to n do For j:=1 to m do begin Read(T); B[i,j]:=T mod 2; End; For i:=1 to n do begin For j:=1 to m do begin If B[i,j]=1 then begin For i1:=1 to k do begin if i+v[i1].x<=n then begin if j+v[i1].y<=m then A[i+v[i1].x,j+v[i1].y]:=not A[i+v[i1].x,j+v[i1].y]; if j-v[i1].y>=1 then A[i+v[i1].x,j-v[i1].y]:=not A[i+v[i1].x,j-v[i1].y]; End; if i-v[i1].x>=1 then begin if j+v[i1].y<=m then A[i-v[i1].x,j+v[i1].y]:=not A[i-v[i1].x,j+v[i1].y]; if j-v[i1].y>=1 then A[i-v[i1].x,j-v[i1].y]:=not A[i-v[i1].x,j-v[i1].y]; End; If (i-v[i1].x<1) and (i+v[i1].x>n) then break; End; For I1:=1 to n do A[I1,j]:=not A[I1,j]; For I1:=1 to m do A[i,i1]:=not A[i,i1]; A[i,j]:=not A[i,j]; End; End; End; For i:=1 to n do begin For j:=1 to m do If A[i,j] then write('W') else write('B'); Writeln; End; End. | |
Категория: Пакет решений на 15.03.08 | Добавил: solver (15.03.2008) | |
Просмотров: 715 |