結果

問題 No.430 文字列検索
ユーザー FF256grhyFF256grhy
提出日時 2016-10-24 03:47:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,611 ms / 2,000 ms
コード長 1,524 bytes
コンパイル時間 174 ms
コンパイル使用メモリ 29,952 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-03 05:19:21
合計ジャッジ時間 12,170 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
6,812 KB
testcase_01 AC 452 ms
6,944 KB
testcase_02 AC 1,089 ms
6,940 KB
testcase_03 AC 777 ms
6,940 KB
testcase_04 AC 0 ms
6,940 KB
testcase_05 AC 0 ms
6,940 KB
testcase_06 AC 0 ms
6,944 KB
testcase_07 AC 0 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 1,505 ms
6,944 KB
testcase_12 AC 1,483 ms
6,940 KB
testcase_13 AC 1,483 ms
6,944 KB
testcase_14 AC 1,611 ms
6,940 KB
testcase_15 AC 1,473 ms
6,944 KB
testcase_16 AC 767 ms
6,940 KB
testcase_17 AC 713 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:33:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   33 |         scanf("%s%d", s, &m);
      |         ~~~~~^~~~~~~~~~~~~~~
main.cpp:34:26: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   34 |         inc(i, m) { scanf("%s", c[i]); }
      |                     ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <cstdio>
#include <cmath>

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

typedef long long   signed int LL;
typedef long long unsigned int LU;

template<typename T> void swap(T &x, T &y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T &a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T &a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int m;
char s[50001];
char c[5000][11];
int ans;

int main() {
	scanf("%s%d", s, &m);
	inc(i, m) { scanf("%s", c[i]); }
	
	int len = 0;
	while(s[len] != '\0') { len++; }
	
	inc(i, m) {
		inc(j, len) {
			int k = 0;
			bool flag = true;
			while(c[i][k] != '\0') {
				if(s[j + k] != c[i][k]) { flag = false; break; }
				k++;
			}
			if(flag) { ans++; }
		}
	}
	
	printf("%d\n", ans);
	
	return 0;
}
0