結果

問題 No.342 一番ワロタww
ユーザー jjjj
提出日時 2016-10-02 16:59:52
言語 Fortran
(gFortran 13.2.0)
結果
WA  
実行時間 -
コード長 1,649 bytes
コンパイル時間 224 ms
コンパイル使用メモリ 29,228 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-13 16:52:11
合計ジャッジ時間 1,031 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 WA -
testcase_12 AC 1 ms
4,376 KB
testcase_13 WA -
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

program main
  implicit none
  character*300::Stmp,S
  character*3,parameter::w='w'
  character*300::Sw,output
  integer::len,wlen,start,before,i,swlen,j
  logical::isoutput=.false.
  read *,Stmp
  do i=1,LEN_TRIM(Stmp),3
     if(.not.str_eq(Stmp(i:i+2),w(1:3))) exit
  end do
  S = Stmp(i:)

  len = LEN_TRIM(S)
  wlen = get_wlen(S)
  if(wlen.ne.0) then
     Sw = REPEAT(w,wlen)
     swlen = wlen*LEN_TRIM(w)
     start = 1
     do i=2,len
        if(str_eq(S(i:i+swlen-1),Sw(1:swlen))) then
           do j=i-1,1,-1
              if(str_eq(S(j:j+2),w)) then
                 before = j+3
                 exit
              end if
           end do
           print '(a)',S(before:i-1)
           isoutput = .true.
        end if
     end do
  end if
  if(isoutput.eqv..false.) print '(a)',""
contains
  function str_eq(S1,S2) result(equal)
    character(*)::S1,S2
    integer::len,i
    logical::equal
    equal=.true.
    len = LEN_TRIM(S2)
    do i=1,len
       if(S1(i:i).ne.S2(i:i)) then
          equal = .false.
          return
       end if
    end do
  end function str_eq
  function get_wlen(S) result(wlen)
    character(*)::S
    character*3,parameter::w='w'
    integer::i,j,len,wmax=0,wlen,wprev
    len = LEN_TRIM(S)
    wlen = 0
    wprev = 0
    do j=1,len-2
       if(S(j:j+2).eq.w(1:3)) then
          if((wprev+3.ge.j.or.wprev.eq.0)) then
             wprev = j
             wlen = wlen + 1
             wmax = MAX(wmax, wlen)
          else
             wprev = j
             wlen = 1
             wmax = MAX(wmax, wlen)
          end if
       end if
    end do
    wlen = wmax
  end function get_wlen
end program main
0