結果
| 問題 |
No.342 一番ワロタww
|
| コンテスト | |
| ユーザー |
jj
|
| 提出日時 | 2016-10-02 16:59:52 |
| 言語 | Fortran (gFortran 14.2.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,649 bytes |
| コンパイル時間 | 194 ms |
| コンパイル使用メモリ | 33,876 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-21 13:04:38 |
| 合計ジャッジ時間 | 877 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 7 WA * 7 |
ソースコード
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
jj