結果
問題 | No.430 文字列検索 |
ユーザー | ikd |
提出日時 | 2016-10-03 10:43:03 |
言語 | C++11 (gcc 11.4.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 729 bytes |
コンパイル時間 | 671 ms |
コンパイル使用メモリ | 58,672 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-05-01 11:14:37 |
合計ジャッジ時間 | 21,857 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 1,413 ms
6,940 KB |
testcase_02 | TLE | - |
testcase_03 | TLE | - |
testcase_04 | AC | 1 ms
6,944 KB |
testcase_05 | RE | - |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 6 ms
6,940 KB |
testcase_09 | RE | - |
testcase_10 | AC | 4 ms
6,944 KB |
testcase_11 | TLE | - |
testcase_12 | TLE | - |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
ソースコード
#include <iostream> using namespace std; #define int long long int powpow(int a, int b){ int ret=1; for(int i=0; i<b; i++){ ret*=a; } return ret; } int calc(string t){ int ret=0; for(int i=0; i<t.size(); i++){ ret+=(t[i]-'A')*powpow(26, i); } return ret; } signed main() { string S; cin>> S; int M; cin>> M; string C[M]; for(int i=0; i<M; i++) cin>> C[i]; int ans=0; for(int k=0; k<M; k++){ int key=calc(C[k]); int keylen=C[k].size(); int text=calc(S.substr(0, keylen)); for(int i=0; i<=S.size()-keylen; i++){ if(key==text) ans++; text-=S[i]-'A'; text/=26; text+=(S[i+keylen]-'A')*powpow(26, keylen-1); } //if(key==text) ans++; } cout<< ans<< endl; return 0; }