結果
| 問題 |
No.43 野球の試合
|
| コンテスト | |
| ユーザー |
jj
|
| 提出日時 | 2017-01-29 03:49:01 |
| 言語 | Fortran (gFortran 14.2.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,090 bytes |
| コンパイル時間 | 455 ms |
| コンパイル使用メモリ | 36,516 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-23 22:41:00 |
| 合計ジャッジ時間 | 905 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 5 WA * 2 |
コンパイルメッセージ
Main.f90:90:30:
90 | write(cformat(5:9),'(i0)'),size(array)
| 1
Warning: Legacy Extension: Comma before i/o item list at (1)
ソースコード
program main
implicit none
integer::N,i,j,tmp,winnum,num,minnum
character::c
character*6::S(6)
integer*8,allocatable::games(:,:)
integer*8,parameter::win=2,lose=0,self=9, none=1
type game
integer::a,b
end type game
type(game)::yet(10)
yet(:)%a=0
yet(:)%b=0
read *,N
allocate(games(1:N,1:N))
read *,S(1:N)(1:N)
do i=1,N
games(i,i) = self
do j=i+1,N
c = S(i)(j:j)
if(c.eq.'o') then
games(i,j) = win
games(j,i) = lose
else if(c.eq.'x') then
games(i,j) = lose
games(j,i) = win
else if(i.eq.1) then
games(i,j) = win
games(j,i) = lose
else
games(i,j) = none
games(j,i) = none
end if
end do
end do
winnum = COUNT(games(1,:).eq.win)
do i=2, N
tmp = COUNT(games(i,:).eq.win)
if(tmp.gt.winnum) then
do j=3, N
if(games(i,j).eq.none) then
games(i,j) = win
games(j,i) = lose
end if
end do
end if
end do
num = 0
do i=2, N
do j=i+1, N
if(games(i,j).eq.none) then
num = num + 1
yet(num)%a = i
yet(num)%b = j
end if
end do
end do
minnum = N
do i=0, 2**num-1
do j=0, num-1
if(btest(i, j).eqv..true.) then
games(yet(j+1)%a,yet(j+1)%b) = win
games(yet(j+1)%b,yet(j+1)%a) = lose
else
games(yet(j+1)%a,yet(j+1)%b) = lose
games(yet(j+1)%b,yet(j+1)%a) = win
end if
end do
minnum = MIN(minnum, get_grade())
end do
print '(i0)', minnum
contains
function get_grade() result(w)
integer::i,j,w
integer::totalwin(num)
do i=1,N
totalwin(i) = COUNT(games(i,:).eq.win)
end do
w = COUNT(totalwin(2:N).gt.totalwin(1)) + 1
end function get_grade
subroutine aprinter(array)
integer*8::array(:)
character*32::cformat='(i0, (1x,i0))'
write(cformat(5:9),'(i0)'),size(array)
write(*,cformat) array
end subroutine aprinter
end program main
jj