Codeforces 368B. Sereja and Suffixes Solution

Solve in C++:
  1. ///**********ALLAH IS ALMIGHTY************///
  2. ///AH Tonmoy
  3. ///Department of CSE
  4. ///Islamic University,Bangladesh
  5. #include<iostream>
  6. #include<set>
  7. using namespace std;
  8. set<int>s;
  9. int main()
  10. {
  11. set<int>s;
  12. int m,n,k,s1[100009],i,r,j;
  13. cin>>n>>m;
  14. for(i=1; i<=n; i++)
  15. {
  16. cin>>s1[i];
  17. }
  18. for(i=n; i>0; i--)
  19. {
  20. s.insert(s1[i]);
  21. s1[i]=s.size();
  22. }
  23. for(i=1;i<=m;i++)
  24. {
  25. cin>>r;
  26. cout<<s1[r]<<endl;
  27. }
  28. return 0;
  29. }
  30.  

No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h &g...

Powered by Blogger.