| 5 | vector<int> v; |
| 6 | bitset<N>bs[26], oc; |
| 7 | int main() { |
| 8 | int i, j, k, n, q, l, r; |
| 9 | string s, p; |
| 10 | cin >> s; |
| 11 | for(i = 0; s[i]; i++) bs[s[i] - 'a'][i] = 1; |
| 12 | cin >> q; |
| 13 | while(q--) { |
| 14 | cin >> p; |
| 15 | oc.set(); |
| 16 | for(i = 0; p[i]; i++) oc &= (bs[p[i] - 'a'] >> i); |
| 17 | cout << oc.count() << endl; // number of occurences |
| 18 | int ans = N, sz = p.size(); |
| 19 | int pos = oc._Find_first(); |
| 20 | v.push_back(pos); |
| 21 | pos = oc._Find_next(pos); |
| 22 | while(pos < N) { |
| 23 | v.push_back(pos); |
| 24 | pos = oc._Find_next(pos); |
| 25 | } |
| 26 | for(auto x : v) cout << x << ' '; // position of occurences |
| 27 | cout << endl; |
| 28 | v.clear(); |
| 29 | cin >> l >> r; // number of occurences from l to r,where l and r is 1-indexed |
| 30 | if(sz > r - l + 1) cout << 0 << endl; |
| 31 | else cout << (oc >> (l - 1)).count() - (oc >> (r - sz + 1)).count() << endl; |
| 32 | } |
| 33 | return 0; |
| 34 | } |
nothing calls this directly
no test coverage detected