結果

問題 No.154 市バス
ユーザー jjjj
提出日時 2016-09-11 15:02:24
言語 Fortran
(gFortran 13.2.0)
結果
WA  
実行時間 -
コード長 1,151 bytes
コンパイル時間 1,643 ms
コンパイル使用メモリ 32,000 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 09:55:38
合計ジャッジ時間 2,148 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
5,248 KB
testcase_01 AC 16 ms
5,376 KB
testcase_02 AC 15 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 16 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 11 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

program main
  implicit none
  integer::T,i
  character*1000::S
  read *,T
  do i=1,T
     read *,S
     call analyze(S)
  end do
contains
  subroutine analyze(S)
    integer::j,len,w,g,r,keitou
    character*1000::S

    len = LEN_TRIM(S)
    w = 0
    g = 0
    r = 0
    do j=1,len
       if(S(j:j).eq.'R') then
          r = r + 1
          if(r.gt.g.or.r.gt.w) then
             print '(a)',"impossible"
             return
          end if
       else if(S(j:j).eq.'G') then
          g = g + 1
          if(g.gt.w) then
             print '(a)',"impossible"
             return
          end if
       else
          w = w + 1
       end if
    end do
    w = 0
    g = 0
    r = 0
    do j=len,1,-1
       if(S(j:j).eq.'R') then
          r = r + 1
       else if(S(j:j).eq.'G') then
          g = g + 1
          if(r.eq.0) then
             print '(a)',"impossible"
             return
          end if
       else
          w = w + 1
          if(r.eq.0.or.g.eq.0) then
             print '(a)',"impossible"
             return
          end if
       end if
    end do
    print '(a)',"possible"
  end subroutine analyze

end program main
0