結果
問題 | No.515 典型LCP |
ユーザー |
![]() |
提出日時 | 2017-05-05 23:40:15 |
言語 | Fortran (gFortran 14.2.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,375 bytes |
コンパイル時間 | 1,604 ms |
コンパイル使用メモリ | 32,896 KB |
実行使用メモリ | 13,888 KB |
最終ジャッジ日時 | 2024-09-14 09:20:27 |
合計ジャッジ時間 | 6,577 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 2 |
other | RE * 2 TLE * 1 -- * 12 |
コンパイルメッセージ
Main.f90:58:30: 58 | write(cformat(5:9),'(i0)'),size(array) | 1 Warning: Legacy Extension: Comma before i/o item list at (1)
ソースコード
program mainimplicit noneinteger*8::Ncharacter*800000,allocatable::S(:)integer*8,allocatable::i(:),j(:)integer*8::k,M,x,d,summread *,Nallocate(S(N))do k=1,Nread *,S(k)end doallocate(i(N),j(N))read *, M, x, dcall query(N,M,x,d,i,j)summ = 0do k=1,Msumm = summ + get_lcp(S,i(k),j(k))end doprint '(i0)',summcontainsinteger*8 function get_lcp(S,ik,jk) result(lcp)character*800000,allocatable,intent(in)::S(:)integer*8::ik,jkinteger*8::silen,sjlen,iilcp = 0do ii=1,MIN(LEN_TRIM(S(ik)),LEN_TRIM(S(jk)))if(S(ik)(ii:ii).eq.S(jk)(ii:ii)) thenlcp = lcp + 1elseexitend ifend doend function get_lcpsubroutine query(N,M,x,d,i,j)integer*8::tmp,kinteger*8,intent(in)::M,d,Ninteger*8,intent(inout)::xinteger*8,allocatable::i(:),j(:)do k=1, Mi(k) = (x/(N-1))+1j(k) = MOD(x,(N-1))+1if(i(k).gt.j(k)) thentmp = j(k)j(k) = i(k)i(k) = tmpelsej(k) = j(k) + 1end ifx = MOD((x+d),N*(N-1))end doend subroutine querysubroutine aprinter(array)integer*8::array(:)character*32::cformat='(i0, (1x,i0))'write(cformat(5:9),'(i0)'),size(array)write(*,cformat) arrayend subroutine aprinterend program main