結果
| 問題 |
No.1005 BOT対策
|
| コンテスト | |
| ユーザー |
pengin_2000
|
| 提出日時 | 2021-09-06 00:22:09 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 651 bytes |
| コンパイル時間 | 292 ms |
| コンパイル使用メモリ | 27,088 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-20 01:38:26 |
| 合計ジャッジ時間 | 1,200 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:5:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
5 | scanf("%s%s", s, t);
| ^~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
int main()
{
char s[1003], t[1003];
scanf("%s%s", s, t);
int i, n, m;
for (n = 0; s[n] != '\0'; n++);
for (m = 0; t[m] != '\0'; m++);
int cnt = 0;
if (m == 1)
{
for (i = 0; i < n; i++)
if (s[i] == t[0])
cnt++;
if (cnt > 0)
printf("-1\n");
else
printf("0\n");
return 0;
}
int ans = 0;
char ss[2003];
int l = 0, j;
for (i = 0; i < n; i++)
{
ss[l] = s[i];
l++;
if (m <= l)
{
cnt = 0;
for (j = l - m; j < l; j++)
if (ss[j] != t[j - l + m])
cnt++;
if (cnt == 0)
{
ans++;
ss[l] = ss[l - 1];
ss[l - 1] = '.';
l++;
}
}
}
printf("%d\n", ans);
return 0;
}
pengin_2000