結果
問題 |
No.1005 BOT対策
|
ユーザー |
![]() |
提出日時 | 2021-05-27 14:17:55 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 471 bytes |
コンパイル時間 | 183 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-11-06 08:48:57 |
合計ジャッジ時間 | 2,013 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 WA * 16 |
ソースコード
def z_algo(s): n=len(s) A=[0]*n j=c=0 for i in range(1,n): if i+A[i-c]<c+A[c]: A[i]=A[i-c] else: j=max(0,c+A[c]-i) while i+j<n and s[j]==s[i+j]: j+=1 A[i]=j c=i A[0]=n return A s,t=input(),input() i=0;num=len(t);ans=0 check=z_algo(t+s) if len(s)==1: print(-1);exit() while i<len(s+t): if check[i]==num: ans+=1 i+=num else: i+=1 print(ans)