Advertisement
asuna12

522

Mar 29th, 2020
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5. int n, x[1005], k;
  6. cin >> n >> k;
  7. for(int i = 1 ; i <= n ; ++ i)
  8. cin >> x[i];
  9. int p = 0, q = 0;
  10. for(int i = 1 ; i < n - k && !p ; ++i)
  11. for(int j = i + 1 ; j <= n - k + 1 && !p; j ++)
  12. {
  13. bool ok = true;
  14. for(int v = 0; v < k && ok ; v ++)
  15. if(x[i + v] != x[j + v])
  16. ok = false;
  17. if(ok)
  18. p = i, q = j;
  19. }
  20. if(p)
  21. cout << p << " " << q;
  22. else
  23. cout << "NU";
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement