結果
問題 | No.1005 BOT対策 |
ユーザー |
![]() |
提出日時 | 2021-05-27 14:19:57 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 515 bytes |
コンパイル時間 | 192 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-11-06 08:50:38 |
合計ジャッジ時間 | 2,095 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 WA * 10 |
ソースコード
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 t not in s: print(0);exit() if len(s)==1 or len(t)==1: print(-1);exit() while i<len(s+t): if check[i]==num: ans+=1 i+=num else: i+=1 print(ans)