結果
問題 | No.430 文字列検索 |
ユーザー | tossy |
提出日時 | 2016-10-02 23:07:33 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 140 ms / 2,000 ms |
コード長 | 1,055 bytes |
コンパイル時間 | 1,118 ms |
コンパイル使用メモリ | 94,844 KB |
実行使用メモリ | 19,368 KB |
最終ジャッジ日時 | 2023-08-15 17:23:29 |
合計ジャッジ時間 | 3,198 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 140 ms
19,288 KB |
testcase_02 | AC | 110 ms
19,288 KB |
testcase_03 | AC | 108 ms
19,264 KB |
testcase_04 | AC | 1 ms
4,376 KB |
testcase_05 | AC | 2 ms
4,376 KB |
testcase_06 | AC | 2 ms
4,376 KB |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 136 ms
19,368 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 12 ms
5,204 KB |
testcase_11 | AC | 128 ms
19,236 KB |
testcase_12 | AC | 130 ms
19,196 KB |
testcase_13 | AC | 129 ms
19,196 KB |
testcase_14 | AC | 131 ms
19,288 KB |
testcase_15 | AC | 130 ms
19,232 KB |
testcase_16 | AC | 112 ms
19,240 KB |
testcase_17 | AC | 111 ms
19,360 KB |
ソースコード
#include <cstdio> #include <cstring> #include <string> #include <cmath> #include <cassert> #include <iostream> #include <algorithm> #include <stack> #include <queue> #include <vector> #include <set> #include <map> #include <bitset> using namespace std; #define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define rep(i,n) repl(i,0,n) #define mp(a,b) make_pair(a,b) #define pb(a) push_back(a) #define all(x) (x).begin(),(x).end() #define dbg(x) cout<<#x"="<<x<<endl #define fi first #define se second #define INF 2147483600 char c[50010]; int main(){ vector<vector<string> > vec(10, vector<string>()); scanf("%s", c); string s(c); int n = s.length(); rep(i,n){ rep(len, 10){ if(i+len>n) continue; vec[len].pb(s.substr(i,len+1)); } } rep(i,10) sort(all(vec[i])); int m; cin>>m; int res=0; rep(loop, m){ char ch[15]; scanf("%s", ch); string str(ch); int len=str.size(); res += upper_bound(all(vec[len-1]), str) - lower_bound(all(vec[len-1]), str); } cout<<res<<endl; return 0; }