結果
| 問題 |
No.1005 BOT対策
|
| コンテスト | |
| ユーザー |
@abcde
|
| 提出日時 | 2020-03-13 21:58:47 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 817 bytes |
| コンパイル時間 | 1,376 ms |
| コンパイル使用メモリ | 163,548 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-20 00:50:51 |
| 合計ジャッジ時間 | 2,370 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | scanf("%s %s", c1, c2);
| ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
// ※※※ 解答不能 ※※※.
// https://yukicoder.me/submissions/436625
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
int main(){
char c1[1010], c2[1010];
scanf("%s %s", c1, c2);
string S(c1), T(c2);
if(string(S).find(T) == -1){
puts("0");
}else{
if(T.size() == 1){
puts("-1");
}else{
int ans = 0;
int L = T.size();
rep(i, S.size() + 1 - L){
if(S.substr(i, L) == T){
ans++;
i += L - 2;
}
}
printf("%d\n", ans);
}
}
return 0;
}
@abcde