program main implicit none type hand character::RC integer::index end type hand integer::H,W,N,i,j,index character::rc type(hand),allocatable::hands(:) integer,allocatable::board(:,:) integer,parameter::white=0,black=1 read *,H,W read *,N allocate(hands(N)) allocate(board(W,H)) read *,hands do i=1,H do j=1,W board(j,i) = MOD((i+j),2) !ichimatsu end do end do do i=1,N rc = hands(i)%RC index = hands(i)%index+1 select case(rc) case ('R') board(1:W,index) = [board(W,index),board(1:W-1,index)] case ('C') board(index,1:H) = [board(index,H),board(index,1:H-1)] end select end do if(board(1,1).eq.white) then print '(a)',"white" else print '(a)',"black" end if contains subroutine slide_r() integer::ii end subroutine slide_r subroutine state() integer::ii,jj do ii=1,H do jj=1,W-1 write(*,'(i0)',advance='no'),board(jj,ii) end do print '(i0)',board(W,ii) end do print *,"" end subroutine state end program main