結果

問題 No.1005 BOT対策
ユーザー pto8913pto8913
提出日時 2020-03-06 21:57:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 740 bytes
コンパイル時間 669 ms
コンパイル使用メモリ 66,316 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-22 11:19:13
合計ジャッジ時間 1,708 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
5,376 KB
testcase_12 WA -
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 WA -
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 WA -
testcase_29 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>

using namespace std;

#define rep(i, a, n) for(int i = a; i < (n); ++i)

int main(){
    string S, T;
    cin >> S >> T;
    int LengthT = T.length();
    int LengthS = S.length();

    if (LengthS <= LengthT || LengthT == 1)
    {
        if (S == T && LengthT != 1)
        {
            cout << 1 << endl;
        }
        else
        {
          cout << -1 << endl;
        }
        return 0;
    }
    
    int count = 0;
    rep(i, 0, LengthS - LengthT + 1)
    {
        string Temp = "";
        rep(j, i, i+LengthT)
        {
            Temp += S[j];
        }
        if (Temp == T)
        {
            ++count;
          	i += LengthT - 1;
        }
    }
    cout << count << endl;
}
0