Advertisement
theo830

suffix

May 4th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. int main() {
  5. std::string a;
  6. int q;
  7. std::cin>>a>>q;
  8. for(int i=0;i<q;i+=1){
  9. int x;
  10. std::cin>>x;
  11. std::string b = a.substr(0,x);
  12. auto its = std::mismatch(a.rbegin(), a.rend(),b.rbegin());
  13. int s = distance(its.first.base(),a.end());
  14. std::cout<<s<<"\n";
  15. }
  16. return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement