CARVIEW |
Select Language
HTTP/2 200
date: Wed, 15 Oct 2025 04:27:03 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=2c073ac4178320d5f26b3070317a261b6a233e166560b2efda0eb0a7a700b020a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22FckzM4PO1AeBwL4TXSrmzq0HcYWkoh34%22%3B%7D; HttpOnly; Path=/
cf-ray: 98ec8fce69963585-BLR
kmp - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int t, line, n, m, ar[1000100], ar2[10010], P[10010];
- void prefix_function(){
- int i, k = -1;
- P[0] = k;
- for (i = 1; i < m; i++){
- while (k > -1 && (ar2[k + 1] != ar2[i])) k = P[k];
- if (ar2[i] == ar2[k + 1]) k++;
- P[i] = k;
- }
- }
- int kmp(){
- int i, k = -1;
- for (i = 0; i < n; i++){
- while (k > -1 && ar2[k + 1] != ar[i]) k = P[k];
- if (ar[i] == ar2[k + 1]) k++;
- if (k == (m - 1)){
- return (i - k + 1);
- }
- }
- return (-1);
- }
- int main(){
- int i, j;
- scanf("%d", &t);
- for (line = 1; line <= t; line++){
- scanf("%d %d", &n, &m);
- for (i = 0; i < n; i++) scanf("%d", &ar[i]);
- for (i = 0; i < m; i++) scanf("%d", &ar2[i]);
- prefix_function();
- int res = kmp();
- printf("%d\n", res);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
-
💡 Instant BTC Profit Method ✅ Working
JavaScript | 8 sec ago | 0.24 KB
-
📝 MAKE $2500 IN 15 MIN ✅ Working
JavaScript | 18 sec ago | 0.24 KB
-
🚀 Swapzone +37% glitch
JavaScript | 27 sec ago | 0.24 KB
-
⭐⭐⭐GMAIL Logs (2FA disabled)⭐⭐
Java | 34 sec ago | 0.15 KB
-
💎 ChangeNOW Exploit
JavaScript | 36 sec ago | 0.24 KB
-
⭐⭐⭐Make $15OO in 2O minutesV E⭐⭐
Java | 44 sec ago | 0.15 KB
-
💡 EASY MONEY GUIDE ✅ Working
JavaScript | 46 sec ago | 0.24 KB
-
⚡ Crypto Swap Glitch ✅ Working ⚡
JavaScript | 54 sec ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand