結果

問題 No.380 悪の台本
ユーザー jjjj
提出日時 2017-03-19 00:31:33
言語 Fortran
(gFortran 13.2.0)
結果
RE  
実行時間 -
コード長 2,272 bytes
コンパイル時間 929 ms
コンパイル使用メモリ 32,256 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 14:55:25
合計ジャッジ時間 1,804 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 WA -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 WA -
testcase_08 RE -
testcase_09 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

subroutine correct()
  print '("CORRECT (maybe)")'
end subroutine correct
subroutine wrong()
  print '("WRONG!")'
end subroutine wrong
function is_kigou(c) result(l)
  character::c
  integer::cnum
  logical::l
  cnum=ICHAR(c)
  l = .not.(((ICHAR('0')<=cnum).and.(cnum<=ICHAR('9'))).or. &
            ((ICHAR('a')<=cnum).and.(cnum<=ICHAR('z'))))
end function is_kigou
program main
  implicit none
  interface
     subroutine wrong()
     end subroutine wrong
     subroutine correct()
     end subroutine correct
  end interface
  integer::N,len,i
  logical::l
  character*100000::S
  do
     read (*,'(1000a)') S
     if(S =="") exit
     len=LEN_TRIM(S)
     if(len.le.5) then
        call wrong()
        cycle
     end if
     call lowering(S)
     if(S(1:4)=="digi") then
        l = search(S, "nyo")
     else if(S(1:5)=="petit") then
        l = search(S,"nyu")
     else if(S(1:4)=="rabi") then
        l = rabi(S)
     else if(S(1:4)=="gema") then
        l = search(S,"gema")
     else if(S(1:4)=="piyo") then
        l = search(S,"pyo")
     end if
     if(l.eqv..true.) then
        call correct()
     else
        call wrong()
     end if
  end do

contains
  subroutine lowering(S)
    character*100000::S
    integer::snum
    do i=1,len
       snum=ICHAR(S(i:i))
       if((65<=snum).and.(snum<=90)) S(i:i)=ACHAR(snum+32)
    end do
  end subroutine lowering
  function search(S,pattern) result(l)
    interface
       function is_kigou(c) result(l)
         character::c
         logical::l
       end function is_kigou
    end interface
    integer::i
    logical::l
    character*100000::S
    character*3,intent(in)::pattern
    l = .false.
    do i=0,3
       if(S(len-2-i:len-i)==pattern) then
          l = .true.
          return
       end if
       if(.not.(is_kigou(S(len-i:len-i)))) then
          exit
       end if
    end do
  end function search
  function rabi(S) result(l)
    interface
       function is_kigou(c) result(l)
         character::c
         logical::l
       end function is_kigou
    end interface
    integer::i
    logical::l
    character*100000::S
    l = .false.
    do i=5,len
       if(.not.(is_kigou(S(i:i)))) then
          l = .true.
          return
       end if
    end do
  end function rabi
end program main
0