fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5. int t;
  6. cin >> t;
  7. while(t--){
  8. int a, b;
  9. string ciag, podciag;
  10. cin >> a >> ciag >> b >> podciag;
  11. int p = 0;
  12. int max = 0;
  13. int mmax = 0;
  14. for(int i = 0; i < b; i++){
  15. for(int j = i; j < b; j++){
  16. for(int k = p; k < a; k++){
  17. if(podciag[j] == ciag[k]){
  18. max++;
  19. p = k;
  20. break;
  21. }
  22. p = 0;
  23. }
  24. }
  25. if(max > mmax)
  26. mmax = max;
  27. max = 0;
  28. }
  29. cout << mmax << endl;
  30. }
  31. }
Success #stdin #stdout 0.01s 5560KB
stdin
2
10
deskorolka
9
stokrotka
5
rafal
5
nowak
stdout
6
1