結果
| 問題 | 
                            No.342 一番ワロタww
                             | 
                    
| コンテスト | |
| ユーザー | 
                             jj
                         | 
                    
| 提出日時 | 2016-10-02 16:51:30 | 
| 言語 | Fortran  (gFortran 14.2.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,372 bytes | 
| コンパイル時間 | 684 ms | 
| コンパイル使用メモリ | 33,268 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-11-21 13:04:33 | 
| 合計ジャッジ時間 | 1,337 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 1 | 
| other | AC * 8 WA * 6 | 
ソースコード
program main
  implicit none
  character*300::S
  character*3,parameter::w='w'
  character*300::Sw,output
  integer::len,wlen,start,before,i,swlen,j
  read *,S
  len = LEN_TRIM(S)
  wlen = get_wlen(S)
  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)
     end if
  end do
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
            
            
            
        
            
jj