結果
| 問題 | 
                            No.1005 BOT対策
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-06-28 20:32:40 | 
| 言語 | Swift  (6.0.3)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 118 ms / 2,000 ms | 
| コード長 | 448 bytes | 
| コンパイル時間 | 9,187 ms | 
| コンパイル使用メモリ | 205,440 KB | 
| 実行使用メモリ | 19,456 KB | 
| 最終ジャッジ日時 | 2025-06-20 01:38:15 | 
| 合計ジャッジ時間 | 11,073 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 29 | 
ソースコード
import Foundation
var s = String(readLine()!)
let t = String(readLine()!)
var q = s
var c = 0
if t.count == 1 && s.contains(t){
    print(-1)
}else if s.contains(t){
    let i = t.index(before: t.endIndex)
    let p = t[...t.index(before: i)] + "." + t[i...]
    while q.contains(t){
        let r = q.range(of: t)!
        q = q.replacingOccurrences(of: t, with: p,range: r)
    }
    print(q.count - s.count)
}else{
    print(q.count - s.count)
}