Advertisement
Infiniti_Inter

Untitled

Mar 20th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. const int maxn = 1050;
  2.  
  3. vector < int > ans;
  4. vector < int > newAns;
  5.  
  6. char t1[maxn];
  7. char t2[maxn];
  8.  
  9. int n, m;
  10. scanf ( "%d%d\n", &n, &m );
  11. gets( t1 );
  12. gets( t2 );
  13.  
  14. for ( int j = 0; j < n; j++ )
  15. ans.pb( j );
  16.  
  17. for ( int j = 0; j < m - n + 1; j++ ) {
  18. newAns.clear();
  19. for ( int i = 0; i < n; i++ )
  20. if ( t1[i] != t2[i + j] )
  21. newAns.pb( i );
  22. if ( newAns.size() < ans.size() )
  23. ans = newAns;
  24. }
  25. int sz = ans.size();
  26. printf( "%d\n", sz );
  27. for ( int j = 0; j < sz; j++ )
  28. printf( "%d ", ans[j] + 1 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement